#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, n, dk, dp, y, ii, jj;
  char s[25];
  char c, m;
  scanf("%s %d", s, &k);
  n = strlen(s);
  for (i = 0; i < n; i++) {
    m = s[i];
    y = i;
    for (j = i + 1; j < n; j++) {
      if (m < s[j] && j - i <= k) {
        y = j;
        m = s[j];
      }
    }
    for (ii = y; ii > i; ii--) {
      c = s[ii];
      s[ii] = s[ii - 1];
      s[ii - 1] = c;
    }
    k -= y - i;
  }
  printf("%s\n", s);
  return 0;
}
