#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const int MAX = 1e7;
const int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string a;
  int k;
  while (cin >> a >> k) {
    for (int i = 0; i < a.length(); i++) {
      if (!k) break;
      char mx = '/';
      int ind = -1;
      for (int j = i; j < a.length() && j - i <= k; j++) {
        if (a[j] > mx) mx = a[j], ind = j;
      }
      if (ind != -1) {
        k -= (ind - i);
        while (ind > 0 && ind != i) swap(a[ind - 1], a[ind]), ind--;
      }
    }
    cout << a << "\n";
  }
  return 0;
}
