Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/stack-k-raqamni-ochirish

Remove k digits

Hard 2000 ms 128 MB 67%
Share

A positive integer $N$ (it may be very long) and an integer $k$ are given. Delete exactly $k$ digits from the notation of $N$ (the order of the remaining digits does not change) so that the resulting number is as small as possible. Print this number without unnecessary leading zeros (if all digits are zeros, print $0$).

Digits of the number: the deleted digits are crossed out, the remaining ones form the smallest number

Input

The first line contains $N$, the second line contains $k$.

Output

The smallest resulting number.

Note

the notation of $N$ has $1$ to $2 \cdot 10^{5}$ digits and does not start with $0$
$0 \le k \lt$ the number of digits of $N$

Examples

Input #1
1432219
3
Output #1
1219
Input #2
10200
1
Output #2
200

Sign in to submit a solution

Signing up is free and takes a minute.