#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1000000000;
const long long int MOD = 1000000007;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  register long long int i, j, x, y, m, n, t, k, sum = 0, max, count = 0, temp,
                                                 w, q;
  string s;
  cin >> s >> k;
  n = s.size();
  for (i = 0; i < n - 1; i++) {
    long long int pos = i;
    max = s[i] - '0';
    for (j = i + 1; j <= min(k + i, n - 1); j++) {
      if (s[j] - '0' > max) {
        max = s[j] - '0';
        pos = j;
      }
    }
    char c = s[pos];
    for (j = pos; j > i; j--) {
      s[j] = s[j - 1];
    }
    s[i] = c;
    if (pos - i == k)
      break;
    else {
      k -= (pos - i);
    }
  }
  cout << s;
}
