n=int(input()) k=int(input()) x=0 for i in range(1,n+1): if i==k: x+=1 if i>=10: if i%10==k: x+=1 if i//10==k: x+=1 print(x)