#include <fstream>
#include <string>

using namespace std;

main()
{
    ifstream fi("xaumax.inp");
    ofstream fo("xaumax.out");
    string s;
    int n;
    getline(fi,s);
    fi >> n;
    for (int i = 0; i < s.length(); i++)
        while (s[i] > 57) {s.erase(i,1); n--;}
    int i = 0;
    if (n > 0)
    {
        while (i < s.length()-1 && n > 0)
        {
            while (s[i] < s[i+1] && n > 0)
            {
                s.erase(i,1);
                n--;
            }
            while (i > 0 && s[i] > s[i-1] && n > 0)
            {
                s.erase(i-1,1);
                n--; i--;
            }
            i++;
        }
    }
    i = s.length()-1;
    if (n > 0)
    {
        while (i > 0 && n > 0)
        {
            if (s[i] <= s[i-1] && n > 0)
            {
                s.erase(i,1);
                n--;
            }
            i--;
        }
    }
    fo << s;
    return 0;
}
