n, x = map(int, input().split())
c = 0
for i in range(n):
    c += str(i + 1).count(str(x))
print(c)