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