#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int k;
  cin >> k;
  for (int i = 0; i < str.size(); ++i) {
    int max_ind = i;
    int j = i + 1;
    while (j < str.size() && j <= i + k) {
      if (str[max_ind] < str[j]) max_ind = j;
      j++;
    }
    if (max_ind == i) continue;
    for (int j = max_ind; j > i; --j) {
      swap(str[j], str[j - 1]);
      k--;
    }
  }
  cout << str;
}
