#include <bits/stdc++.h>
using namespace std;
int main() {
  int abmged_moves, abmged_counter = 0;
  string abmged_n;
  cin >> abmged_n >> abmged_moves;
  for (int i = 0; i + 1 < abmged_n.size() && abmged_moves; i++) {
    int abmged_x = i;
    int abmged_char = abmged_n[i];
    for (int j = i + 1; j < abmged_n.size() && j - i <= abmged_moves; j++) {
      if (abmged_n[j] > abmged_char) {
        abmged_x = j;
        abmged_char = abmged_n[j];
      }
    }
    abmged_moves -= abmged_x - i;
    for (int j = abmged_x; j > i; j--) {
      swap(abmged_n[abmged_x], abmged_n[abmged_x - 1]);
      abmged_x--;
    }
  }
  cout << abmged_n << endl;
  return 0;
}
