#include <bits/stdc++.h>
using namespace std;
struct node {
  char decimal;
  int flag;
  bool operator<(const node &b) const {
    if (decimal > b.decimal)
      return 1;
    else if (decimal == b.decimal) {
      if (flag < b.flag)
        return 1;
      else
        return 0;
    } else
      return 0;
  }
};
int main() {
  char figure[20];
  node a[20];
  int k, len;
  while (cin >> figure >> k) {
    len = strlen(figure);
    for (int i = 0; i < len; i++) {
      int t = i;
      for (int j = i + 1; j <= i + k && j < len; j++) {
        if (figure[j] > figure[t]) t = j;
      }
      char temp = figure[t];
      for (int j = t; j > i; j--) {
        figure[j] = figure[j - 1];
        k--;
      }
      figure[i] = temp;
      if (k == 0) break;
    }
    cout << figure << endl;
  }
}
