#include <stdio.h>

int main() {

    int a = 0;
    int b = 0;
    scanf("%d %d", &a, &b);//a是范围,b是要判断的数字
    int arr[1000000] = {0};//a的最大范围
    int i;
    int count = 0;
    for (i = 0; i < a; i++)//给数组赋值
    {
        arr[i] = i + 1;
    }
    //arr[10]={1,2,3,4,5,6,7,8,9,10}
    int j;
    for (j = 0; j < a; j++)//判断出现次数
    {
        int c = arr[j];
        while (c != 0)
        {
            if (c % 10 == b)
            {
                count++;
            }
            c /= 10;//按位查找
        }
    }
    
    printf("%d\n", count);
    return 0;
}