String by Deletions

View as PDF

Submit solution


Points: 100
Time limit: 1.0s
Memory limit: 977M

Problem type

You are given a decimal string s and an integer k.

Delete exactly k digits from s 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 s.

The second line contains the integer k.

Output

Print the smallest possible number after deleting exactly k digits.

Constraints

  • 1 \le |s| \le 2 \cdot 10^5
  • 0 \le k \le |s|
  • s consists only of digits 0 through 9

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

There are no comments at the moment.