//求一个长为m的数组中删除n数后组成最小数字
int main()
{
//新整数长度
while (true)
{
string num, res;
int k;
cin >> num >> k;
int newLength = num.length() - k;
//创建一个栈,用来接收所有数字
char* stack = new char[num.length()];
int top = 0;
for (int i = 0; i<num.length(); i++) {
char c = num.at(i);
//当栈顶的值大于正在遍历的数字,就出栈。即top–,将当前遍历的值给到栈顶位置
while (top>0 && stack[top - 1]>c && k>0) {
top -= 1;
k -= 1;
}
stack[top] = c;
top++;
}
int offset = 0;
while (offset < newLength && stack[offset] == '0') {
offset++;
}
string *s = new string(stack, offset, newLength - offset);
if (offset == newLength)
{
cout << '0';
}
else
{
cout << *s;
}
}
return 0;
}