#include <bits/stdc++.h>
char s[32];
int len;
void swap(int st, int end, int k);
int main(void) {
  int k;
  scanf("%s%d", s, &k);
  len = strlen(s);
  swap(0, len, k);
  puts(s);
  return 0;
}
void swap(int st, int end, int k) {
  int i, max;
  char t;
  if (!k || st == end) return;
  for (max = i = st; i < end; i++)
    if (s[i] > s[max]) max = i;
  if (max - st <= k) {
    k -= max - st;
    t = s[max];
    for (i = max; i > st; i--) s[i] = s[i - 1];
    s[i] = t;
    swap(st + 1, len, k);
    return;
  }
  swap(st, max, k);
  return;
}
