#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.length();
  int count = 0, i = 0, p;
  while (count < k && i < n) {
    p = i;
    int t = s[i];
    for (int j = i; j < min(n - 1, i + k - count); j++)
      if (t < s[j + 1]) {
        p = j + 1;
        t = s[j + 1];
      }
    for (int j = min(n - 1, p); j > i; j--) swap(s[j], s[j - 1]);
    count += p - i;
    i++;
  }
  for (int i = 0; i < n; i++) {
    cout << s[i] - '0';
  }
  cin >> n;
}
