#include<iostream>
using namespace std;
int main(){
int a,b,j=0;
cin>>a>>b;
for(int i=1;i<=a;i++){
int d=i;
while(d>0){
int c=d%10;
d/=10;
if(c==b){
j++;
}
}
}
cout<<j;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x;
cin >> n >> x;
stringstream ss;
for (n++; --n; ss << n);
string s = ss.str();
cout << count(s.begin(), s.end(), x + '0') << endl;
return 0;
}
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,tot=0,x;
int zh(ll a){
char ch[10];
memset(ch,'0',sizeof(ch));
snprintf(ch,sizeof(ch),"%lld",a);
ll sum=0;
for(int i=0;i<strlen(ch);i++){
if(ch[i]==x+'0')
sum++;
}
return sum;
}
int main(){
cin>>n>>x;
for(int i=1;i<=n;i++){
tot+=zh(i);
}
cout<<tot;
return 0;
}