#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = acos(-1.0);
template <class Int>
Int __gcd(Int a, Int b) {
  return (b == 0 ? abs(a) : __gcd(b, a % b));
}
int dx[] = {0, 0, -1, 1, 1, 1, -1, -1};
int dy[] = {-1, 1, 0, 0, 1, -1, -1, 1};
const int N = 2e5 + 10;
void file() {}
bool ok(string s) {
  string t = s;
  sort(((t).rbegin()), ((t).rend()));
  return s == t;
}
string solve(string s, int k) {
  if (k == 0 || ok(s)) return s;
  string r = s;
  for (int i = 0; i < ((int)(s).size()) - 1; i++) {
    if (s[i] < s[i + 1]) {
      string t = s;
      swap(t[i], t[i + 1]);
      r = max(r, solve(t, k - 1));
    }
  }
  return r;
}
int main() {
  file();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  int k;
  cin >> s >> k;
  for (int i = 0; i < ((int)(s).size()); i++) {
    char ch = s[i];
    int idx = i;
    for (int j = i + 1; j < min(i + k + 1, ((int)(s).size())); j++) {
      if (s[j] > ch) {
        ch = s[j];
        idx = j;
      }
    }
    for (int j = idx; j > i; j--) {
      swap(s[j], s[j - 1]);
      k--;
    }
  }
  cout << s << endl;
}
