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