#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x,g=0,h;
    cin>>n>>x;
    for(int i=1;i<=n;i++){
        h=i;
        while(h>0){
            if(h%10==x) g++;
            h/=10;
        }
    }
    cout<<g;
}
/**************************************************************
	Problem: 1469
	User: yangjunwen
	Language: C++
	Result: Accepted
	Time:29 ms
	Memory:2072 kb
****************************************************************/