#include <bits/stdc++.h>
using namespace std;
string s;
long n, ans, k, b[100], a[100];
long long g;
long sqr(long a) { return (a * a); }
int main() {
  cin >> g >> k;
  long kk = 0;
  while (g > 0) {
    b[kk] = g % 10;
    g /= 10;
    kk++;
  }
  for (int i = 0; i < kk; i++) {
    a[kk - i - 1] = b[i];
  }
  for (int i = 0; i < kk; i++) {
    long curmax = a[i], curi = i;
    for (int j = i; j <= min(kk + 1, i + k); j++) {
      if (curmax < a[j]) {
        curmax = a[j];
        curi = j;
      }
    }
    k -= curi - i;
    if (i != curi)
      for (int j = curi; j > i; j--) {
        long f = a[j];
        a[j] = a[j - 1];
        a[j - 1] = f;
      }
  }
  for (int i = 0; i < kk; i++) {
    cout << a[i];
  }
  return 0;
}
