#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

ll n2;

struct BIT {
    ll n;
    vll a;
    BIT(ll n = n2) : n(n), a(n + 1, 0) {}
    void add(ll i, ll w){
        for(ll x = i; x <= n; x += x & -x) a[x] += w;
    }
    ll sum(ll i) { // sum of [1, i]
        ll ret = 0;
        for(int x = i; x > 0; x -= x & -x) ret += a[x];
        return ret;
    }
    ll sum(ll l, ll r) { // sum of [l, r]
        return sum(r) - sum(l - 1);
    }
};

void solve() {
    string s;
    ll k;
    cin >> s >> k;
    n2 = s.size();
    BIT b[26];
    queue<ll> q[26];
    for(ll i = 0; i < n2; i++) {
        ll j = s[i] - 'a';
        b[j].add(i + 1, 1);
        q[j].push(i + 1);
    }
    string ans;
    for(ll i = 0; i < n2; i++) {
        for(ll j = 0; j < 26; j++) {
            if(q[j].empty()) continue;
            ll f = q[j].front();
            ll cnt = 0;
            for(ll l = 0; l < 26; l++) {
                cnt += b[l].sum(f - 1);
            }
            if(cnt <= k) {
                ans += 'a' + j;
                q[j].pop();
                b[j].add(f, -1);
                k -= cnt;
                break;
            }
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}
