import java.util.*; public class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); String line; while (scan.hasNextLine()) { line = scan.nextLine().trim(); // please write your code here String str[] = line.split(" "); int len = str[0].length(); int k = Integer.parseInt(str[1]); int num[] = new int[len]; for(int i=0;i<len;i++) num[i] = str[0].charAt(i)-‘0‘; // System.out.println("answer"); System.out.println(Main.removeKdigits(num,k)); } } private static String removeKdigits(int []num,int k){ if(num.length==0||k>=num.length) return "0"; int i=0; int rmnum=0; LinkedList<Integer> stack = new LinkedList<>(); for(;i<num.length;i++){ while(!stack.isEmpty() && stack.peek()>num[i] && rmnum<k){///判断是否为递减数列,是就出栈,去掉高位 stack.pop(); rmnum++; } if(rmnum>=k) break; if(num[i]!=0) stack.push(num[i]);///去掉0位 } while(rmnum<k) {///如果还没删除k位,继续出栈就行 stack.pop(); rmnum++; } String ans=""; while(!stack.isEmpty()) ans = stack.pop() +ans;///连接字符串 while(ans.length()==0&&i<num.length&&num[i]==0) i++;///如果出现0开头的字符串,则删除前面的0 while(i<num.length) { ans+=num[i]+""; i++; } if(ans.length()==0) return "0"; return ans; } }