#include <bits/stdc++.h>
using namespace std;
template <typename T>
using maxHeap = priority_queue<T, vector<T>, less<T>>;
template <typename T>
using minHeap = priority_queue<T, vector<T>, greater<T>>;
template <typename Iter>
ostream& _out(ostream& s, Iter b, Iter e) {
  s << "[";
  for (auto it = b; it != e; it++) s << (it == b ? "" : " ") << *it;
  s << "]";
  return s;
}
template <typename A, typename B>
ostream& operator<<(ostream& s, const pair<A, B>& p) {
  return s << "(" << p.first << "," << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& c) {
  return _out(s, begin(c), end(c));
}
bool debug = 0;
template <typename T>
void DEBUG(const T& x) {
  if (debug) cerr << x;
}
template <typename T, typename... Args>
void DEBUG(const T& head, const Args&... tail) {
  if (debug) {
    cerr << head;
    DEBUG(tail...);
  }
}
int arr[20];
int main(int argc, char* argv[]) {
  if (argc > 1 and string(argv[1]) == "-D") debug = 1;
  if (!debug) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  }
  string a;
  int k;
  cin >> a >> k;
  string la = a;
  sort(begin(la), end(la));
  reverse(begin(la), end(la));
  int n = (int)(a.size());
  while (k > 0 and a != la) {
    iota(arr, arr + n, 0);
    sort(arr, arr + n, [a](int x, int y) {
      int xx = -x, yy = -y;
      return tie(a[x], xx) > tie(a[y], yy);
    });
    for (int i = 0; i < n; i++) DEBUG(arr[i], " \n"[i == n - 1]);
    bool flag = true;
    for (int p = 0; p < n; p++) {
      for (int j = 0; j < n; j++) {
        int bian = arr[j];
        if (bian < p) continue;
        if (bian == p or a[bian] == a[p]) break;
        if (debug)
          cerr << __PRETTY_FUNCTION__ << ":" << 84 << " - "
               << "bian"
               << "=" << bian << '\n';
        if (k - (bian - p) >= 0) {
          k -= (bian - p);
          flag = false;
          for (int _ = bian - 1; _ >= p; _--) {
            swap(a[_], a[_ + 1]);
            DEBUG(_, " ", _ + 1, '\n');
          }
          if (debug)
            cerr << __PRETTY_FUNCTION__ << ":" << 92 << " - "
                 << "a"
                 << "=" << a << '\n';
          break;
        }
      }
      if (!flag) break;
    }
  }
  cout << a << '\n';
  return 0;
}
