import java.util.Scanner;
public class Main2 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int n,x;
n=scanner.nextInt();
x=scanner.nextInt();
String a=Integer.toString(x);
int num=0;
int j=0;
StringBuilder sb=new StringBuilder();
for (int i = 0; i < n; i++) {
sb.append(i+1);
}
String[] str=sb.toString().split("");
for (int i = 0; i < str.length; i++) {
if(str[i].contains(a) ) num++;
}
System.out.println(num);
}
}