#include <iostream>
using namespace std;
int main()
{
int k, n;
cin >> n >> k;
int ans = 0;
for (int i = 1; i <= n; i++)
{
int j = i;
while (j)
{
if (j % 10 == k)
ans++;
j /= 10;
}
}
cout << ans;
return 0;
}