#include <bits/stdc++.h>
using namespace std;
long long OO = LLONG_MAX, M = 1e9 + 7, EPS = 1e6;
const double pi = acos(-1);
int main() {
  string s;
  int k;
  cin >> s >> k;
  for (int i = 0; i < s.size(); i++) {
    char mx = s[i];
    int idx = i;
    for (int j = i + 1; j < s.size(); j++) {
      if (s[j] > mx && j - i <= k) {
        mx = s[j];
        idx = j;
      }
    }
    for (int j = idx; j > i; j--) swap(s[j], s[j - 1]);
    k -= idx - i;
    if (!k) break;
  }
  cout << s;
  return 0;
}
