#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
vector<int> d[10];
int main() {
  string s;
  int k;
  cin >> s >> k;
  int pos = 0;
  while (k > 0) {
    int m = pos;
    for (int j = pos + 1; j < s.length() && j - pos <= k; ++j)
      if (s[j] > s[m]) m = j;
    if (m != pos) {
      char x = s[m];
      s.erase(m, 1);
      s.insert(pos, 1, x);
      k -= m - pos;
    }
    ++pos;
    if (pos == s.length()) break;
  }
  cout << s;
  return 0;
}
