#include <bits/stdc++.h>
using namespace std;
int di[] = {0, 0, 0, -1, 1}, dj[] = {0, 1, -1, 0, 0};
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
int main() {
  ios::sync_with_stdio(false);
  string s;
  long long k;
  cin >> s >> k;
  for (int i = 0; i < (int)s.size(); i++) {
    int pos = i;
    for (int j = i + 1; j < (int)s.size() && j - i <= k; j++) {
      if (s[pos] < s[j]) pos = j;
    }
    if (pos != i) {
      k = k - (pos - i);
      for (int j = pos; j > i; j--) {
        swap(s[j], s[j - 1]);
      }
    }
  }
  cout << s;
  return 0;
}
