#include <bits/stdc++.h>
using namespace std;
char s[100];
int n, k;
int main() {
  scanf("%s %d", s, &k);
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    int pos = max_element(s + i, s + min(i + k + 1, n)) - s;
    if (s[pos] <= s[i]) continue;
    while (k && pos != i) {
      swap(s[pos], s[pos - 1]);
      pos--;
      k--;
    }
  }
  printf("%s\n", s);
  return 0;
}
