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