#include <bits/stdc++.h>
using namespace std;
void sw(char& a, char& b) { a ^= b ^= a ^= b; }
int main() {
  long long tmp, a, k, i, j;
  char ar[20];
  cin >> a >> k;
  int l = 0;
  tmp = a;
  while (tmp > 0) {
    ar[l++] = tmp % 10 + '0';
    tmp /= 10;
  }
  ar[l] = '\0';
  int pro = 0, ind;
  char val;
  for (j = l - 1; j >= 0; j--) {
    val = ar[j], ind = j;
    if (pro >= k) break;
    for (i = j - 1; i >= 0; i--) {
      if (pro + j - i <= k && ar[i] > val) {
        ind = i;
        val = ar[i];
      }
    }
    for (i = ind; i < j; i++) sw(ar[i], ar[i + 1]);
    pro += j - ind;
  }
  for (i = l - 1; i >= 0; i--) cout << ar[i];
  cout << endl;
  return 0;
}
