#include <bits/stdc++.h>
using namespace std;
string s;
int n, m,i=0,t=0,f=0;
char a[1000000];
bool check(char a)
{
    return '0'<=a&&a<='9';
}
int main()
{
    freopen("xaumax.inp","r",stdin);
    freopen("xaumax.out","w",stdout);
    getline(cin,s);
    cin>>n;
    for (int i=0;i<s.size();i++)
    {
        if (check(s[i]))
        {
            a[m]=(s[i]);
            m++;
        }
    }
    n=n-(s.size()-m);
    i=0;
    while (n>0)
    {
        while (a[i]=='a')
        {
            i++;
        }
        t=i+1;
        while (a[t]=='a')
        {
            t++;
        }
        if (a[i]<a[t])
        {
            a[i]='a';
            n--;
            i=0;
        }
        else i++;
    }
    for (int i=0;i<m;i++)
    {
        if (a[i]!='a')
            cout<<a[i];
    }
}
