#include <bits/stdc++.h>
using namespace std;
const int maxn = 120;
const int INF = 0x3f3f3f3f;
char ch[maxn];
int main() {
  int k;
  while (cin >> ch >> k) {
    int len = strlen(ch);
    int a = 0;
    while (k && a < len) {
      int mx = 0, id = -1;
      for (int i = a; i <= a + k; i++) {
        if (ch[i] > mx) mx = ch[i], id = i;
      }
      for (int i = id; i > a; i--) {
        swap(ch[i], ch[i - 1]);
        k--;
      }
      a++;
    }
    puts(ch);
  }
}
