n,x = input().split()
n = int(n)

count = 0
for i in range(1,n+1):
    i = str(i)
    for j in i:
        if j == x:
            count += 1

print(count)