#include <stdio.h>

int main() {
    int num1 = 0;
    int num2 = 0;
    int count = 0;
    while (scanf("%d %d", &num1, &num2) != EOF) 
    { 
        for (int i = 1; i<=num1;i++)
        {
            int temp = i;
            while (temp)
            {
                if (temp%10 == num2)
                {
                    count++;
                }

                temp /= 10;
            }
        }
    }

    printf("%d",count);
    return 0;
}