#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  for (int i = 0; i < s.length(); i++) {
    if (k <= 0) break;
    char x = s[i];
    int index = -1;
    for (int j = i + 1; j <= i + k; j++) {
      if (j >= s.length()) break;
      if (s[j] > x) {
        x = s[j];
        index = j;
      }
    }
    if (x > s[i]) {
      for (int j = index; j > i; j--) {
        s[j] = s[j - 1];
        k--;
      }
      s[i] = x;
    }
  }
  cout << s << endl;
  return 0;
}
