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