#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, i, j, y, maxim, w;
  string aux;
  string a;
  cin >> a;
  cin >> k;
  if (k == 0)
    cout << a;
  else {
    for (i = 0; i < a.size(); i++) {
      maxim = -1;
      w = 0;
      for (j = i; w <= k and j < a.size(); j++) {
        w += 1;
        if ((a[j] - '0') > maxim) {
          maxim = a[j] - '0';
          y = j;
        }
      }
      if (y - i <= k)
        for (j = y; j >= i + 1; j--) {
          aux[0] = a[j];
          a[j] = a[j - 1];
          a[j - 1] = aux[0];
          k -= 1;
        }
    }
    for (i = 0; i < a.size(); i++) cout << a[i];
  }
  return 0;
}
