#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  int k;
  cin >> s;
  cin >> k;
  int n = s.size();
  int ind = -1;
  for (int i = 0; i < n - 1 && k > 0; i++) {
    ind = i + 1;
    for (int j = i + 2; j < n && j - i <= k; j++) {
      if (s[ind] < s[j]) ind = j;
    }
    if (ind - i <= k && s[ind] > s[i]) {
      k -= ind - i;
      for (int j = ind; j > i; j--) swap(s[j], s[j - 1]);
    }
  }
  cout << s;
  return 0;
}
