import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        sc.close();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            String s = Integer.toString(i);
            for (char c : s.toCharArray()) if (c - '0' == k) count++;
        }
        System.out.println(count);
    }
}