#include <stdio.h>

int main()
{
    int n;
    int x;
    int count = 0;
    scanf("%d %d", &n, &x);
    for (int i = 1; i <= n; i++)
    {
        int temp = i;
        while(temp)
        {
            if(temp % 10 == x)
            {
                count++;
            }
            temp = temp / 10;
        }
    }
    printf("%d", count);
    return 0;

}