#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
const int maxn = 1010;
stack<int> sta;
int main(){
int ans[maxn];
string str;
int k;int i;
while(cin>>str>>k){
sta.push(str[0]-'0');
for(i=1;i<str.size();i++){
while(k&&sta.size()&&(sta.top()>str[i]-'0')) {
sta.pop();
k--;
}
sta.push(str[i]-'0');
}
while(k--)
sta.pop();
int j=0;
while(sta.size()) {
ans[j++] = sta.top();
sta.pop();
}
for(i = j-1; !ans[i] ;i--);
if(i<0) printf("0");
for(; i >= 0; i--)
printf("%d" , ans[i]);
puts("");
}
return 0;
}