#include<stdio.h>
int main()
{
    int a,b;
    int i;
    int count=0;
    scanf("%d %d",&a,&b);
    for(i=1;i<=a;i++)
    {
        int m=i;
        while (m)
        {
            if (m % 10 == b)
                count++;
            m /= 10;
        }
     }
    printf("%d",count);
}