#include <bits/stdc++.h>
using namespace std;
string s;
int k, n;
int main() {
  ios::sync_with_stdio(0);
  cin >> s >> k;
  char maxs;
  int n = s.length();
  for (int i = (0), _b = (n - 1); i < _b; i++) {
    maxs = i;
    for (int j = (i + 1), _b = (min(i + k + 1, n)); j < _b; j++) {
      if (s[j] > s[maxs]) maxs = j;
    }
    for (int j = (maxs - 1), _b = (i); j >= _b; j--) swap(s[j], s[j + 1]);
    k -= (maxs - i);
  }
  cout << s;
  return 0;
}
