#include <bits/stdc++.h>
using namespace std;
long long s;
int k, np;
int p[111];
int main() {
  cin >> s >> k;
  np = 0;
  while (s) {
    np++;
    p[np] = s % 10;
    s /= 10;
  }
  for (int i = np; i >= 1; i--) {
    int pick = i, temp;
    for (int j = i; j >= max(i - k, 1); j--)
      if (p[j] > p[pick]) pick = j;
    while (pick != i) {
      temp = p[pick];
      p[pick] = p[pick + 1];
      p[pick + 1] = temp;
      pick++;
      k--;
    }
  }
  for (int i = np; i >= 1; i--) printf("%d", p[i]);
  return 0;
}
