n,x=map(int,input().split()) list1=[] for i in range(1,n+1): if str(x) in str(i): list1.append(str(i).count(str(x))) print(sum(list1))