#include <bits/stdc++.h>
using namespace std;
int main() {
  string sh;
  cin >> sh;
  int k;
  cin >> k;
  string res = "";
  for (int i = 0; i <= sh.length() - 1; i++) {
    char maxx = sh[i];
    int Index = i;
    for (int j = i + 1; j <= min((int)sh.length() - 1, i + k); j++) {
      if (sh[j] > maxx) {
        maxx = sh[j];
        Index = j;
      }
    }
    for (int j = Index; j >= i + 1; j--) swap(sh[j], sh[j - 1]);
    res += maxx;
    k -= Index - i;
  }
  cout << res << endl;
}
