#include <iostream>
using namespace std;
int main()
{
int n,x;
cin>>n>>x;
int count = 0;
for(int i = 1;i <= n;i++)
{
int a = i;
while(a > 0)//分离位数
{
if(a % 10 == x)
{
count++;
}
a /= 10;
}
}
cout<<count;
return 0;
}