#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const double EPS = 10e-9;
const int SIZE = 20;
char number[SIZE];
vector<int> dig[SIZE];
inline void mySwap(int i, int j) {
  char tmp = number[j];
  for (typeof(j) k = (j); k >= (i + 1); --k) number[k] = number[k - 1];
  number[i] = tmp;
}
void fun(int n, int k) {
  int bg = 0;
  for (; bg < n; ++bg) {
    for (typeof(9) i = (9); i >= (0); --i) {
      if (i <= number[bg] - '0') break;
      for (typeof(bg + 1) j = (bg + 1); j < (n); ++j) {
        if (number[j] - '0' == i) {
          if (k >= j - bg) {
            k -= j - bg;
            mySwap(bg, j);
            ++bg;
            if (!k) return;
          }
        }
      }
    }
  }
}
void rob() {
  int k;
  scanf("%s %d", number, &k);
  int n = strlen(number);
  fun(n, k);
  printf("%s\n", number);
}
int main() {
  int test = 1;
  while (test--) rob();
  return 0;
}
