#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  for (int i = 0; i < s.length(); i++) {
    int mx = s[i] - '0', mi = 0, mj = 0;
    if (k <= 0) break;
    for (int j = i + 1; j < s.length(); j++)
      if (s[i] - '0' < s[j] - '0' && s[j] - '0' > mx && k >= j - i) {
        mx = s[j] - '0';
        mi = i;
        mj = j;
      }
    if (mx != s[i] - '0')
      for (int e = mj; e > i; e--) {
        swap(s[e], s[e - 1]);
        k--;
      }
  }
  cout << s << "\n";
  return 0;
}
