#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long i, j, k;
  long long co = 0;
  scanf("%lld", &k);
  for (i = 0; i < s.size(); i++) {
    for (long long l = i; l < s.size(); l++) {
      char ma = s[i];
      long long ind = -1;
      for (j = i + 1; co < k && j < s.size(); j++) {
        if (ma < s[j]) {
          ma = s[j];
          ind = j;
        }
        co++;
      }
      long long to = 0;
      if (ind != -1) {
        long long key = s[ind];
        for (j = ind; j > i; j--) {
          s[j] = s[j - 1];
          to++;
        }
        s[i] = key;
        k -= to;
      }
      co = 0;
    }
  }
  cout << s << "\n";
}
