#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int N = 0, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
int n;
char s[20];
void SWAP(int x, int y) {
  for (int i = y; i > x; --i) {
    swap(s[i], s[i - 1]);
  }
}
int main() {
  while (~scanf("%s%d", s, &n)) {
    int m = strlen(s);
    for (int i = 0; i < m; ++i) {
      for (char aim = '9'; aim > s[i]; --aim) {
        for (int j = i; j < m && j - i <= n; ++j) {
          if (s[j] == aim) {
            SWAP(i, j);
            n -= (j - i);
            break;
          }
        }
      }
    }
    puts(s);
  }
  return 0;
}
