#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[10005];
  int k, i, j;
  while (cin >> str >> k) {
    if (k == 0)
      cout << str << endl;
    else {
      int len = strlen(str);
      while (k) {
        for (i = 0; i < len; i++) {
          char t = str[i];
          int flag = -1;
          for (j = 1; j <= k && i + j < len; j++) {
            if (str[i + j] > t) {
              flag = j;
              t = str[i + j];
            }
          }
          if (flag == -1)
            ;
          else {
            int ti;
            k -= flag;
            char tch = str[i];
            char ch;
            str[i] = str[i + flag];
            for (ti = i + 1; ti <= i + flag; ti++) {
              ch = str[ti];
              str[ti] = tch;
              tch = ch;
            }
          }
        }
        break;
      }
      cout << str << endl;
    }
  }
}
