#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, int> P3;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

struct SegmentTree {
    int N;
    vector<int> node;

    SegmentTree(){}
    SegmentTree(int n_){
        init(n_);
    }

    void init(int siz){
        N = 1;
        while (N < siz) N *= 2;
        node.resize(2*N-1, 0);
    }

    void build(vector<int> &dat){
        int siz = dat.size();
        for(int i=0; i<siz; i++){
            node[i+N-1] = dat[i];
        }
        for(int i=N-2; i>=0; i--){
            node[i] = node[2*i+1] + node[2*i+2];
        }
    }

    void update(int k, int a) {
        k += N - 1;
        node[k] = a;
        while (k > 0) {
            k = (k-1)/2;
            node[k] = node[k*2+1] + node[k*2+2];
        }
    }
    int getSum(int a, int b) {return getSum(a, b, 0, 0, N);}
    int getSum(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)
            return 0;
        if (a <= l && r <= b)
            return node[k];
        else {
            int vl = getSum(a, b, k*2+1, l, (l+r)/2);
            int vr = getSum(a, b, k*2+2, (l+r)/2, r);
            return vl + vr;
        }
    }
};

int main() {
    int n, k;
    string s, ans="";
    cin >> s >> k;
    n = s.size();
    vector<int> v(n,1), pos[26];
    SegmentTree rsq(n);
    rsq.build(v);
    REP(i,n){
        pos[s[i]-'a'].push_back(i);
    }
    REP(i,26){
        SORT(pos[i]);
        reverse(ALL(pos[i]));
    }
    REP(i,n){
        REP(j,26){
            if(pos[j].size()>0 && rsq.getSum(0,pos[j].back()) <= k){
                ans.push_back('a'+j);
                k -= rsq.getSum(0,pos[j].back());
                rsq.update(pos[j].back(),0);
                pos[j].pop_back();
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

