#include <bits/stdc++.h>
using namespace std;
vector<int> pos;
string s;
int n;
int main() {
  cin >> s >> n;
  int aux;
  int ind = 1000;
  int saltos = n;
  while (n != 0) {
    int indice = 1000;
    ind = 1000;
    for (int i = s.size() - 1; i > 0; i--) {
      int cont = 0, ind2 = 1000;
      for (int j = i - 1; j >= 0; j--) {
        if (s[i] - '0' > s[j] - '0') {
          cont++;
          ind2 = j;
        } else
          break;
      }
      if (cont > n) {
        ind2 = ind2 + cont - n;
        cont = n;
      }
      if (ind2 < ind && ind2 != 1000) {
        saltos = cont;
        ind = ind2;
        indice = i;
      } else {
        if (ind2 == ind && ind2 != 1000) {
          if (s[i] - '0' > s[indice] - '0') {
            saltos = cont;
            ind = ind2;
            indice = i;
          }
        }
      }
    }
    if (indice != 1000 && ind != 1000)
      for (int i = indice; i > ind; i--) swap(s[i], s[i - 1]);
    else
      break;
    n = n - saltos;
  }
  cout << s << endl;
  return 0;
}
