#include <bits/stdc++.h>
using namespace std;
long long k, t;
string a;
int main() {
  cin >> a >> k;
  for (long long h = 0; h < a.size() - 1; h++) {
    t = h;
    for (long long d = h + 1; d < a.size() && d - h <= k; d++) {
      if (a[d] > a[t]) t = d;
    }
    k -= t - h;
    while (t != h) {
      swap(a[t], a[t - 1]);
      t--;
    }
  }
  cout << a << "\n";
}
