cho.sh
Notes
Loading...

Deleting Digits

Time limit

2s

Memory limit

128 MB

Problem

You are given a digit string with N digits. You must delete all of the specified digits from this string.

If the same digit appears more than once, you may choose which occurrence to delete. Deleting 5 from 12534 produces 1234, and deleting one 5 from 1253452 can produce either 123452 or 125342.

After deleting every specified digit, make the remaining digit string as large as possible. Given the original digit string and the digits that must be deleted, find the largest remaining digit string that can be made.

Input

The first line contains the N-digit string S. N is an integer between 1 and 1,000, inclusive.

The second line contains, without spaces, the digits that must be deleted. The number of digits to delete is less than N, and the input is guaranteed to allow all of those digits to be deleted from S.

Output

Print the largest remaining digit string that can be made after deleting all specified digits.