#include <bits/stdc++.h>
using namespace std;
string s;
int k, p, sz;
void doSwap(int from, int to) {
  int i;
  for (i = to; i > from; i--) {
    swap(s[i], s[i - 1]);
  }
}
void input() {
  cin >> s;
  sz = s.size();
  cin >> k;
}
int findMax(int from, int to) {
  int pos;
  char m;
  m = s[from];
  pos = from;
  int i;
  for (i = from + 1; i <= to; i++) {
    if (s[i] > m) {
      m = s[i];
      pos = i;
    }
  }
  return pos;
}
void solve() {
  int i;
  i = 0;
  while (k && i < sz) {
    p = findMax(i, min(i + k, sz));
    doSwap(i, p);
    k = k - (p - i);
    i++;
  }
  cout << s << endl;
}
int main() {
  input();
  solve();
  return 0;
}
