#include <bits/stdc++.h>
using namespace std;
typedef pair < char, int > Pci;
typedef pair < int , char > Pic;
struct BIT
{
    int data[200005];
    BIT() { memset(data, 0, sizeof(data)); }
    void add(int k, int x) { for(k++; k < 200005; k += (k & -k)) data[k] += x; }
    int query(int k) { int ans = 0; for(k++; k > 0; k -= (k & -k)) ans += data[k]; return (ans); }
};

int main()
{
    string S, ANS;
    int K, N;
    BIT tree;
    Pci data[200005]; 
    priority_queue < Pic , vector < Pic > , greater < Pic > > pq;

    cin >> S >> K;
    N = S.size();
    for(int i = 0; i < N; i++) {
        tree.add(i, 1);
        data[i] = Pci(S[i], i);
    }
    sort(data, data + N);
    int i = 0;
    while(!pq.empty() || i < N) {
        int val;
        if(!pq.empty() && (val = tree.query(pq.top().first) - 1) <= K) {
            K -= val;
            tree.add(pq.top().first, -1);
            ANS.push_back(pq.top().second);
            pq.pop();
        } else if((val = tree.query(data[i].second) - 1) <= K) {
            K -= val;
            tree.add(data[i].second, -1);
            ANS.push_back(data[i].first);
            i++;
        } else {
            pq.push(Pic(data[i].second, data[i].first));
            i++;
        }
    }
    cout << ANS << endl;
    return (0);
}
        