#include <bits/stdc++.h>
using namespace std;
string s;
int k;
int main() {
  cin >> s >> k;
  int iter = 5;
  while (k > 0 and iter--) {
    for (int i = 0; i < (int)s.size(); i++) {
      if (k <= ((int)s.size() - 1 - i)) {
        char maxi = s[i];
        int pos = i;
        for (int j = i; j <= i + k; j++) {
          if (s[j] > maxi) {
            maxi = max(maxi, s[j]);
            pos = j;
          }
        }
        k = k - (pos - i);
        for (int j = pos; j > i; j--) swap(s[j], s[j - 1]);
      } else {
        char maxi = s[i];
        int pos = i;
        for (int j = i; j < (int)s.size(); j++) {
          if (s[j] > maxi) {
            maxi = max(maxi, s[j]);
            pos = j;
          }
        }
        k = k - (pos - i);
        for (int j = pos; j > i; j--) swap(s[j], s[j - 1]);
      }
    }
  }
  cout << s;
}
