#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k, max, index;
  cin >> s >> k;
  for (int i = 0; i < s.size() && k > 0; i++) {
    if (s[i] == '9') continue;
    max = s[i] - '0', index = i;
    for (int j = i + 1; j < k + i + 1 && j <= s.size(); j++) {
      if (s[j] - '0' > max) {
        max = s[j] - '0';
        index = j;
        if (max == 9) break;
      }
    }
    for (int l = index; l > i; l--) {
      swap(s[l], s[l - 1]);
    }
    k -= index - i;
  }
  cout << s << endl;
}
