n,x=map(int,input().split())
count=0
b=0
for i in range(1,n+1):
while i>=1: b=i%10 i/=10 if b==x: count+=1
print(count)