#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  while (n > 0) {
    v.push_back(n % 10);
    n /= 10;
  }
  long long now = v.size() - 1;
  while (now > 0 and k > 0) {
    long long maxx = -1, pos;
    for (long long i = now - 1; i >= 0 and i >= now - k; i--) {
      if (maxx < v[i]) maxx = v[i], pos = i;
    }
    if (maxx <= v[now])
      now--;
    else {
      for (long long i = pos; i < now; i++) {
        swap(v[i], v[i + 1]);
        k--;
      }
      now--;
    }
  }
  for (long long i = v.size() - 1; i >= 0; i--) cout << v[i];
}
