Hide

Problem A
Swap Frenzy

/problems/swapfrenzy/file/statement/en/img-0001.jpg
Image by Katey

You are given a positive integer $n$ and asked to make it larger by swapping pairs of its digits. For each swap, you can choose two digits at different positions and exchange their positions, as long as the swap does not result in a leading zero. What is the largest number you can get after performing exactly $k$ swaps?

Input

The input has a single line with two integers $n$ ($100 \leq n < 10^{18}$) and $k$ ($1 \leq k \leq 18$).

Output

Output the largest number you can get after exactly $k$ swaps.

Sample Input 1 Sample Output 1
1374 2
7413
Sample Input 2 Sample Output 2
210 1
201
Sample Input 3 Sample Output 3
666 3
666

Please log in to submit a solution to this problem

Log in