#include<iostream>
#include<string>
using namespace std;
int main(){
int n,x;
int counter = 0;
string helper;
cin>>n>>x;
for (int i = 1; i<n+1; i++){
helper = to_string(i);
for (int j = 0; j<helper.length(); j++){
if (helper[j] - '0' == x){
counter += 1;
}
}
}
cout<<counter<<endl;
}