#include <bits/stdc++.h>
using namespace std;
string num, sorted_num;
int k;
void solve() {
  cin >> num >> k;
  sorted_num = num;
  sort(sorted_num.begin(), sorted_num.end());
  reverse(sorted_num.begin(), sorted_num.end());
  int n = num.length();
  int curr = 0;
  while (k) {
    int mx = INT_MIN;
    int ind = -1;
    for (int i = curr; i <= min(curr + k, n - 1); i++) {
      if (num[i] - '0' > mx) {
        mx = num[i] - '0';
        ind = i;
      }
    }
    while (ind > 0 && k > 0 && num[ind] - '0' > num[ind - 1] - '0') {
      swap(num[ind], num[ind - 1]);
      ind--;
      k--;
    }
    curr++;
    if (num == sorted_num || ind == -1) break;
  }
  cout << num << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  while (tc--) solve();
  return 0;
}
