#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int k;
  cin >> str >> k;
  int n = str.length();
  int i = 0;
  while (k && i < n) {
    char big = str[i];
    int idx = i;
    for (int j = i + 1; j < n && j - i <= k; j++)
      if (str[j] > big) {
        big = str[j];
        idx = j;
      }
    if (idx > i) {
      int prev = idx - 1;
      while (k && prev >= i) {
        char temp = str[prev];
        str[prev] = str[prev + 1];
        str[prev + 1] = temp;
        prev--;
        k--;
      }
    }
    i++;
  }
  cout << str << endl;
  return 0;
}
