#include <bits/stdc++.h>
using namespace std;
char a[30];
int main() {
  int p = 1;
  while (1) {
    scanf("%c", &a[p]);
    if (a[p] == ' ') break;
    p++;
  }
  int k;
  scanf("%d", &k);
  p -= 1;
  for (int i = 1; i <= p; i++) {
    int xx = i;
    if (k <= 0) break;
    char maxx = a[i];
    if (k + i <= p) {
      for (int j = i + 1; j <= k + i; j++)
        if (maxx < a[j]) {
          maxx = a[j];
          xx = j;
        }
    } else
      for (int j = i + 1; j <= p; j++)
        if (maxx < a[j]) {
          maxx = a[j];
          xx = j;
        }
    if (xx != i) {
      for (int j = xx; j > i; j--) swap(a[j], a[j - 1]);
      k -= xx - i;
    }
  }
  for (int i = 1; i <= p; i++) printf("%c", a[i]);
  return 0;
}
