#include <bits/stdc++.h>
using namespace std;
int main() {
  char n[20];
  int k;
  cin >> n >> k;
  int l = strlen(n), i = 0;
  while (k > 0 && i < l) {
    int x = i;
    for (int j = i + 1; j < l; j++) {
      if (n[j] > n[x] && (k + i - j) >= 0) x = j;
    }
    char z = n[x];
    for (int k = x; k > i; k--) {
      n[k] = n[k - 1];
    }
    n[i] = z;
    k = k - x + i;
    i++;
  }
  cout << n << endl;
  return 0;
}
