#include <bits/stdc++.h>
#pragma comment(linker, "/stack:336777216")
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll const mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  string s;
  int k;
  cin >> s >> k;
  int l = 0;
  while (l < s.size()) {
    char best = s[l];
    int pos = -1;
    for (int i = l + 1; i < min((int)s.size(), l + k + 1); i++) {
      if (s[i] > best) best = s[i], pos = i;
    }
    if (pos == -1) {
      l++;
      continue;
    }
    for (int i = pos - 1; i >= l; i--) swap(s[i], s[i + 1]);
    k -= (pos - l);
    l++;
  }
  cout << s << '\n';
  return 0;
}
