#include<iostream>
using namespace std;
int main()
{
long long n = 0, x = 0, k = 0, k1 = 0, count = 0;
cin >> n >> x;
for (int i = 0; i <=n; i++)
{
if (i == x)
count++;
else
{
k = i;
while (k != 0)
{
k1 = k % 10;
k = k / 10;
if (k1 == x)
count++;
}
}
}
cout << count << endl;
return 0;
}