import java.util.Scanner;
public class Main{
private static Scanner cin;
public static void main(String args[])throws Exception {
cin = new Scanner(System.in);
int n = cin.nextInt();
int x = cin.nextInt();
int count = 0;
StringBuilder sb = new StringBuilder("");
if (x >=0 && x<=9) {
for(int i=1;i<=n;i++) {
sb.append(i);
}
String tmp = String.valueOf(x);
int startLocation = 0;
int index = sb.indexOf(tmp, startLocation);
while(index != -1) {
count++;
startLocation = index+1;
index = sb.indexOf(tmp, startLocation);
}
}
System.out.println(count);
}
}