String by Deletions
View as PDFYou are given a decimal string and an integer
.
Delete exactly digits from
so that the remaining digits, in their original order, form the
smallest possible number.
If the resulting number has leading zeroes, do not print them. If every digit is deleted, or the
result is all zeroes, print 0.
Input
The first line contains the string .
The second line contains the integer .
Output
Print the smallest possible number after deleting exactly digits.
Constraints
consists only of digits
0through9
Example 1
Input
1432219
3
Output
1219
Explanation
Deleting the digits 4, 3, and 2 gives the smallest possible result.
Example 2
Input
10200
1
Output
200
Explanation
Deleting the leading 1 gives 0200, which is printed as 200.
Example 3
Input
10
2
Output
0
Comments