LogiQuest

199. Remove K Digits

MediumMonotonic StackGreedy

Remove k digits from the number to make it as small as possible. Print the result without leading zeros (print 0 if nothing remains).

Input format

Line 1: num (digits) Line 2: k

Output format

The smallest number.

Example 1

Input

1432219
3

Output

1219

Example 2

Input

10200
1

Output

200

Constraints

1 ≤ k ≤ |num| ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…