#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int k;
  string a;
  cin >> a >> k;
  for (int h = 0; h < a.size() - 1; h++) {
    if (a[h] == 9) {
      continue;
    } else {
      char maxDigit = a[h];
      int maxPos = h;
      for (int pos = h + 1; pos < a.size(); pos++) {
        if (pos - h > k) {
          break;
        }
        if (a[pos] > maxDigit) {
          maxDigit = a[pos];
          maxPos = pos;
        }
      }
      k -= maxPos - h;
      a.erase(maxPos, 1);
      a.insert(h, 1, maxDigit);
      if (k == 0) {
        break;
      }
    }
  }
  cout << a << endl;
  return 0;
}
