#include <bits/stdc++.h>
using namespace std;
string in;
int k;
int main(void) {
  cin >> in >> k;
  int maior;
  string res;
  string tmp = in;
  ;
  string tmp2;
  for (int i = 0; i < in.size(); ++i) {
    maior = -0x3f3f3f3f;
    int pos;
    for (int j = 0; j < tmp.size(); ++j) {
      int cost = j;
      if (maior < tmp[j] && cost <= k) {
        maior = tmp[j];
        pos = j;
      }
    }
    tmp2.clear();
    for (int j = 0; j < tmp.size(); ++j) {
      if (j != pos) tmp2 += tmp[j];
    }
    res += tmp[pos];
    k -= pos;
    tmp = tmp2;
  }
  cout << res << "\n";
  return 0;
}
