#33299: _ans


yp11151103@yphs.tp.edu.tw (810-29)


//b330
#include<iostream>
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){ //只有0是FLASE其他的繼續執行 
            if(temp%10==x) ans++;
            temp/=10;
        }
    }
    cout<<ans<<endl;
}
    return 0;
}