#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
int main() {
  string s;
  int k;
  while (cin >> s >> k) {
    int len = s.size();
    for (int i = 0; i < len - 1; i++) {
      int in = i;
      char ch = s[i];
      for (int j = i + 1; j < len && j - i <= k; j++) {
        if (ch < s[j]) {
          ch = s[j];
          in = j;
        }
      }
      k -= in - i;
      while (in != i) {
        swap(s[in], s[in - 1]);
        in--;
      }
      if (k <= 0) break;
    }
    cout << s << endl;
  }
  return 0;
}
