#include <bits/stdc++.h>
using namespace std;
long long maxPos(long long a[], long long i, long long len, long long dist) {
  long long max = a[i], p = -1;
  for (long long j = i + 1; j <= len - 1 && j <= i + dist; j++) {
    if (a[j] > max) {
      max = a[j];
      p = j;
    }
  }
  return p;
}
int main() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long len = s.length();
  long long *a = new long long[len];
  for (long long i = 0; i < len; i++) a[i] = s[i] - '0';
  long long swaps = 0;
  for (long long i = 0; i < len - 1; i++) {
    long long pos = maxPos(a, i, len, k - swaps);
    if (pos != -1) {
      long long swapreq = pos - i;
      if (swapreq && swapreq <= k - swaps) {
        long long l = i;
        long long r = pos;
        long long first = a[l];
        long long last = a[r];
        for (long long q = r; q > l; q--) {
          long long temp = a[q];
          a[q] = a[q - 1];
          a[q - 1] = temp;
        }
        swaps += pos - i;
      }
    }
  }
  for (long long i = 0; i < len; i++) cout << a[i];
  cout << endl;
}
