#include <bits/stdc++.h>
using namespace std;
int main() {
  int i = 1, j = 0, n, m, cc = 0, l = 0, a = 0, b = 0;
  char aa[20], tmp;
  scanf("%s", &aa);
  l = strlen(aa);
  scanf("%d", &n);
  while (n > 0 && j < l) {
    cc = 0;
    if (aa[j] != '9') {
      tmp = aa[j];
      for (i = j; i <= (n + j) && i < l; ++i) {
        if (aa[i] > tmp) {
          a = i;
          b = j;
          tmp = aa[i];
        }
      }
      while (a != b) {
        swap(aa[a], aa[a - 1]);
        --n;
        --a;
      }
    }
    ++j;
  }
  printf("%s\n", aa);
}
