#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100];
  int x;
  scanf("%s%d", s, &x);
  int n = strlen(s), tot = 0;
  for (int i = 0; i < n; i++) {
    int to = -1;
    for (int j = 9; j >= 0; j--) {
      for (int k = i; k < n; k++) {
        if (s[k] == j + '0') {
          to = k;
          break;
        }
      }
      if (to == -1) continue;
      if (tot + to - i <= x) {
        for (int k = to - 1; k >= i; k--) {
          s[k + 1] = s[k];
        }
        tot += to - i;
        s[i] = j + '0';
        break;
      }
    }
  }
  puts(s);
  return 0;
}
