#24623: ___ㄏ


ce5324 (伃)


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x;
while(cin>>n>>x){
int ans=0;
for(int i=1; i<=n; i++)
{
int temp=i;
while(temp){
if(temp%10==x) ans++;
temp/=10;
}
}
cout<<ans<<endl;
}
}