#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[20] = "\0";
  char b[20] = "\0";
  int time;
  while (cin >> a >> time) {
    int max, flag, k, i, st, j;
    int l = strlen(a);
    for (i = 0; i < l; i++) {
      max = a[i];
      flag = 0;
      st = 0;
      for (j = i + 1; j < l && j <= i + time; j++) {
        if (a[j] > max) {
          max = a[j];
          flag = j;
        }
        st++;
        if (time - st == 0) break;
      }
      int temp;
      int x = flag - i;
      if (st > 0 && x > 0) {
        for (int k = flag; k > i; k--) {
          temp = a[k];
          a[k] = a[k - 1];
          a[k - 1] = temp;
        }
        time = time - x;
      }
      if (time == 0) break;
    }
    cout << a << endl;
    strcpy(a, b);
  }
  return 0;
}
