#include <bits/stdc++.h>
int main(void) {
  int k, n, i = 0, count, max, current = 1, index, p, temp;
  int number[18], number1[18];
  long long int a, c;
  scanf("%lld %d", &a, &k);
  c = a;
  while (c > 0) {
    number1[i] = c % 10;
    c = c / 10;
    i++;
  }
  count = i;
  for (i = 0; i < count; i++) {
    number[i] = number1[count - i - 1];
  }
  while (k != 0 && current != count) {
    p = 0;
    max = -1;
    for (i = current; i < count && p < k; i++) {
      if (number[i] > max) {
        index = i;
        max = number[i];
      }
      p++;
    }
    if (max > number[current - 1]) {
      while (index != current - 1) {
        temp = number[index];
        number[index] = number[index - 1];
        number[index - 1] = temp;
        index--;
        k--;
      }
    }
    current++;
  }
  for (i = 0; i < count; i++) printf("%d", number[i]);
  return 0;
}
