#include <bits/stdc++.h>
using namespace std;
int judge(int a,int b)
{
    int c = 0;
    while (a != 0)
    {
        if (a % 10 == b)
        {
            c++;
        }
        a /= 10;
    }
    return c;
    
}
int main()
{
    int cnt = 0;
    int n, x;
    cin >> n >> x;
    for (int i = 1; i <= n; i++)
    {
        cnt += judge(i, x);
    }
    cout << cnt;
    return 0;
}

函数解法喵