n, x = input().split()
n = int(n)
# 直接遍历1~n的每个数字,转字符串后统计x的出现次数,再求和
count = sum(str(num).count(x) for num in range(1, n+1))
print(count)