Weird Rounding
time limit per test 1 second memory limit per test 256 megabytes
Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10k.

In the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10k. For example, if k = 3, in the number 30020 it is enough to delete a single digit (2). In this case, the result is 3000 that is divisible by 103=1000.

Write a program that prints the minimum number of digits to be deleted from the given integer number n, so that the result is divisible by 10k. The result should not start with the unnecessary leading zero (i.e., zero can start only the number 0, which is required to be written as exactly one digit).

It is guaranteed that the answer exists.

传送门:CF779B

Input

The only line of the input contains two integer numbers n and k (0≤n≤2000000000, 1≤k≤9). It is guaranteed that the answer exists. All numbers in the input are written in traditional notation of integers, that is, without any extra leading zeros.

Output

Print w — the required minimal number of digits to erase. After removing the appropriate w digits from the number n, the result should have a value that is divisible by 10k. The result can start with digit 0 in the single case (the result is zero and written by exactly the only digit 0).

Sample Input

1
30020 3

Sample Output

1
1

题解

简单逻辑 从后往前扫,数零的个数
## AC code:(不包含输入类)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.io.*;  
import java.util.*;
public class Main {

public static void main(String[] args) {
FastScanner sc=new FastScanner();
PrintWriter pw=new PrintWriter(System.out);
while(sc.hasNext()){
String s=sc.next();
int k=sc.nextInt();
int count=0;
int index=-1;
for(int i=s.length()-1;i>=0;i--){
if(s.charAt(i)-'0'==0){
count++;
}
if(count==k){
index=i;
break;
}
}
if(index==-1){
pw.println(s.length()-1);
}
else pw.println(s.length()-index-k);
pw.flush();
}

}

}