#include <bits/stdc++.h>
using namespace std;
class cmp {
 public:
  bool operator()(pair<int, int> p1, pair<int, int> p2) {
    if (p1.first == p2.first) return p1.second < p2.second;
    return p1.first > p2.first;
  }
};
int main() {
  char in[100];
  int Kay;
  scanf("%s %d", in, &Kay);
  int i, n = strlen(in), j;
  for (i = 0; i < n; i++) {
    vector<pair<int, int> > vp;
    for (j = i; j < n; j++) {
      vp.push_back(make_pair(in[j] - '0', j - i));
    }
    sort(vp.begin(), vp.end(), cmp());
    for (j = 0; j < vp.size(); j++) {
      if (vp[j].second <= Kay) {
        Kay -= (vp[j].second);
        break;
      }
    }
    int sp = vp[j].second;
    j = i + vp[j].second;
    while (sp--) {
      swap(in[j], in[j - 1]);
      j--;
    }
  }
  printf("%s\n", in);
  return 0;
}
