#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    vector<int> a(20);
    int count = 0;
    while (n > 0) {
      long long int r = n % 10;
      n = n / 10;
      a[count] = r;
      count++;
    }
    for (int i = count - 1; i >= 0; i--) {
      int val = a[i], pos = i, temp = k;
      for (int j = i - 1; j >= 0; j--) {
        if (temp <= 0) break;
        if (a[j] > val) {
          val = a[j];
          pos = j;
        }
        temp--;
      }
      k -= (i - pos);
      int spare = a[pos];
      for (int j = pos; j < i; j++) {
        a[j] = a[j + 1];
      }
      a[i] = spare;
    }
    for (int i = count - 1; i >= 0; i--) {
      cout << a[i];
    }
  }
  return 0;
}
