#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

/* 
PascalCase  クラス名
camelCase   メソッド名，関数名，変数名
snake_case  ファイル名，名前空間，std のメソッド名，変数名，型名に準じる場合
SNAKE_CASE	マクロ名，static const 定数，列挙体
*/

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template <typename T>
class BIT
{
  private:
    int N;
    vector<T> node;

  public:
    BIT(int size)
    {
        N = size;
        node.resize(N + 1, 0);
    }

    /*[1, a]の合計(1-indexed)*/
    T getSum(int i)
    {
        T sum = 0;
        while (i > 0)
        {
            sum += node[i];
            i -= i & -i;
        }

        return sum;
    }

    /*[a, b]の合計(1-indexed)*/
    T getSum(int l, int r)
    {
        T res_l = getSum(l - 1);
        T res_r = getSum(r);

        return res_r - res_l;
    }

    /*i番目にxを追加(1-indexed)*/
    void add(int i, T x)
    {
        while (i <= N)
        {
            node[i] += x;
            i += i & -i;
        }
    }

    /* k番目の値を二分探索(0-indexed) */
    /* res(0-indexed) */
    int lowerBound(int k)
    {
        k++;

        if (k <= 0)
        {
            return 0;
        }

        int init = 1;
        while (init < N)
        {
            init *= 2;
        }

        int res = 0;
        for (int i = init / 2; i > 0; i /= 2)
        {
            if (res + i < N && node[res + i] < k)
            {
                k -= node[res + i];
                res += i;
            }
        }

        return res + 1;
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    int k;
    cin >> s >> k;
    int N = Size(s);

    BIT<int> bit(N);
    queue<int> index[26];

    REP(i, N)
    {
        index[s[i] - 'a'].push(i + 1);
    }

    REP(i, N)
    {
        bit.add(i + 1, 1);
    }

    string ans = "";
    REP(i, N) 
    {
        REP(c, 26)
        {
            if(0 < index[c].size())
            {
                int top = index[c].front();
                int req = bit.getSum(top);
                //cout << top << endl;

                if(req - 1 <= k)
                {
                    ans += char('a' + c);
                    index[c].pop();
                    k -= req - 1;
                    bit.add(top, -1);
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5180