#include<iostream> using namespace std; int main(){ int n,x,i,s; cin>>n>>x; for(i=1;i<=n;i++){ while(i>0){ if(i%10==x){ s++; i=i/10; } } } cout<<s; return 0; }