1 #include<stdio.h> 2 int main() 3 { 4 int i,n,num,tail,head; 5 char q[100],s[100]; 6 while(~scanf("%s%d",s,&n)){ 7 tail=head=num=i=0; 8 q[tail++]=s[i++]; 9 while(s[i]){ 10 if(s[i]>q[tail-1]||num>=n) 11 q[tail++]=s[i++]; 12 else{ 13 if(head==tail){ 14 q[tail++]=s[i++]; 15 }else{ 16 tail--; 17 num++; 18 } 19 } 20 } 21 q[tail]=0; 22 puts(q); 23 } 24 return 0; 25 }