n, k  = map(int,input().split())
count  =  0
for num in range(1,n+1):
    while num >0:
        if num %10 ==k:
            count += 1
        num //= 10
print(count)