#include <bits/stdc++.h>
using namespace std;
string s;
int findmax(int st, int end) {
  if (end < st) return -1;
  int maxi = s[st];
  int pos = st;
  for (int i = st + 1; i <= end; i++) {
    if (s[i] > maxi) {
      maxi = s[i];
      pos = i;
    }
  }
  return pos;
}
void swap(char *a, char *b) {
  char c = *a;
  *a = *b;
  *b = c;
}
void shifts(int m, int n) {
  for (int i = n; i > m; i--) {
    swap(&s[i], &s[i - 1]);
  }
}
int main() {
  int i, j, k, len;
  cin >> s;
  cin >> k;
  len = s.size();
  for (i = 0; i < s.size(); i++) {
    int l = findmax(i + 1, min(k + i, len - 1));
    if (l != -1 && s[l] > s[i]) {
      shifts(i, l);
      k = k - (l - i);
    }
    if (k == 0) break;
  }
  cout << s << endl;
  return 0;
}
