# include <iostream>
using namespace std;
const int N = 2600;
string s;
int q[N];
int k;
bool st[N];
int main()
{
getline(cin,s);
scanf("%d",&k);
int sz =s.size();
int tt=-1,hh=0;
bool flag = false;
for(int i=0;i<sz;i++)
{
while(tt>=hh && s[q[tt]]>s[i])
{
if(k==0)
{
flag = true;
break;
}
st[q[tt]]=true;
tt--;
k--;
}
if(flag)break;
q[++tt]=i;
}
if(k>0)
{
for(int i =sz-1;i>=0&&k>0;i--)
if(!st[i])st[i]=true,k--;
}
int i=0;
while(i<sz&&((!st[i]&&s[i]=='0')||st[i]))i++;
if(i>=sz)printf("0");
else
{
for(;i<sz;i++)
if(!st[i])cout<<s[i];
}
return 0;
}