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