#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k, i, j, d, e;
  char c;
  cin >> k;
  for (i = 0; i < s.size(); i++) {
    if (k == 0) break;
    c = s[i];
    if ((i + k) < s.size())
      e = i + k;
    else
      e = s.size() - 1;
    for (j = i + 1; j <= e; j++) {
      if (s[j] > s[i]) {
        c = max(s[j], c);
      }
    }
    d = -1;
    for (j = i; j <= e; j++) {
      if (s[j] == c) {
        d = j;
        break;
      }
    }
    if (d == -1) continue;
    for (j = d; j > i; j--) {
      c = s[j];
      s[j] = s[j - 1];
      s[j - 1] = c;
      k--;
    }
  }
  cout << s << endl;
}
