#include <bits/stdc++.h>
using namespace std;
long long A;
int K, a[31];
int main() {
  while (cin >> A >> K) {
    int w = 0;
    while (A > 0) {
      a[w++] = A % 10;
      A /= 10;
    }
    for (int i = w - 1; i >= 0; i--) {
      int mf = max(i - K, 0);
      int zd = -1, zdj;
      for (int j = i; j >= mf; j--) {
        if (a[j] > zd) {
          zd = a[j];
          zdj = j;
        }
      }
      int tmp = a[zdj];
      for (int j = zdj; j < i; j++) a[j] = a[j + 1];
      a[i] = tmp;
      K -= i - zdj;
    }
    long long tmp = 1;
    for (int i = 0; i < w; i++) {
      A += tmp * a[i];
      tmp *= 10;
    }
    cout << A << "\n";
  }
  return 0;
}
