#include <bits/stdc++.h>
using namespace std;
string S;
int k;
void solve(int pos, int k) {
  if (k == 0 || pos == S.size()) return;
  int mx = pos;
  for (int i = pos; i < S.size() && i - pos <= k; i++)
    if (S[i] > S[mx]) mx = i;
  for (int i = mx; i > pos; i--) swap(S[i], S[i - 1]);
  solve(pos + 1, k - (mx - pos));
}
int main() {
  cin >> S >> k;
  solve(0, k);
  cout << S << endl;
  return 0;
}
