#include <bits/stdc++.h>
using namespace std;
int A[500];
int main() {
  long long x, k;
  cin >> x >> k;
  int q = 0;
  while (x > 0) {
    A[q] = x % 10;
    x /= 10;
    q++;
  }
  int in = 0;
  while (k > 0 && in < q) {
    int b_from = (q - in - k - 1 > 0 ? q - in - k - 1 : 0);
    int mx = *max_element(A + b_from, A + q - in);
    int ind = 0;
    for (int i = 0; i < q - in; i++)
      if (A[i] == mx) ind = i;
    if (ind == q - in - 1) {
      in++;
      continue;
    }
    for (int i = ind; i < q - in - 1; i++) {
      int r = A[i + 1];
      A[i + 1] = A[i];
      A[i] = r;
      k--;
      if (k <= 0) break;
    }
    in++;
  }
  for (int i = q - 1; i >= 0; i--) cout << A[i];
  return 0;
}
