//丹阳新区实小路彦
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, x;
cin >> n >> x;
int res = 0;
for (int i = 1; i <= n; i++)
for (int j = i; j; j /= 10)
if (j % 10 == x)
res++;
cout << res << endl;
return 0;
}