#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3fffffff;
const int maxn = 110;
char a[20];
int k;
int main() {
  scanf("%s", a);
  cin >> k;
  int len = strlen(a);
  for (int i = 0; i < len; ++i) {
    int p = i;
    for (int j = 1; j <= k && j + i < len; ++j)
      if (a[i + j] > a[p]) p = i + j;
    if (a[p] == a[i]) continue;
    for (int j = p; j > i; --j) swap(a[j], a[j - 1]);
    k -= p - i;
    if (k <= 0) break;
  }
  printf("%s\n", a);
  return 0;
}
