import sys n,x = map(int,input().strip().split()) count = 0 for i in range(1,n+1): if str(x) in str(i): count += str(i).count(str(x)) print(count)