import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        int z = str.indexOf(" ");
        String a = str.substring(0, z);
        String b = str.substring(z + 1, str.length());
        int n = Integer.parseInt(a);
        int x = Integer.parseInt(b);
        int count = 0; 
        
        for(int i = 1; i <= n; i++) {
            if(i == x) {
                count++;
            } else {
                if(i / 10 != 0) {
                    int q = 0;
                    int w = i;
                    while(w != 0) {
                        q = w % 10;
                        if(q == x) {
                            count++;
                        }
                        w /= 10;
                    }
                }
            }
        }
        System.out.println(count);
    }
}