#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[250];
  int k;
  cin >> a;
  cin >> k;
  int temp = k;
  int curr = 0;
  a[strlen(a)] = '\0';
  if (strlen(a) > 1) {
    while (temp) {
      int max_v = a[curr] - 48, max_p = curr;
      for (int j = curr + 1; j <= curr + temp && j < strlen(a); j++) {
        if (a[j] - 48 > max_v) {
          max_v = a[j] - 48;
          max_p = j;
        }
      }
      if (max_p != curr) {
        for (int j = max_p; j > curr; j--) {
          if (temp) {
            swap(a[j], a[j - 1]);
            temp--;
          } else
            break;
        }
      }
      curr++;
      if (curr >= strlen(a)) {
        break;
      }
      a[strlen(a)] = '\0';
    }
  }
  cout << a;
  return 0;
}
