#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  int k = 0;
  cin >> a >> k;
  for (int d = 0; d < a.length(); ++d) {
    if (a[d] == '9') continue;
    int mx = a[d];
    int mxp = d;
    for (int i = d + 1; i < a.length() && i - d <= k; ++i) {
      if (a[i] > mx) {
        mx = a[i];
        mxp = i;
      }
    }
    for (int i = mxp; i > d; --i) {
      swap(a[i], a[i - 1]);
      --k;
    }
  }
  cout << a << endl;
  return 0;
}
