#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,n,i,o=0,s=0;
	cin>>n>>x;
	for(i=1;i<=n;i++){
		o=i;
		while(o!=0){				
			if(o%10==x)
			s++;
			o/=10;
		}
	}
	cout<<s;
	return 0;
}
/**************************************************************
	Problem: 1469
	User: houshanglin
	Language: C
	Result: Compile Error
****************************************************************/