n = int(input())
k = int(input())
count = 0

for i in range(1, n+1):
    if sum([int(x) for x in list(str(i))]) > k-1 and len(str(i)) >= k:
    # if len(str(i)) >= k:
        count += 1
        if i % 10 != k-1 and len(str(i)) > k:
            count -= 1
        if k == int(str(i).replace("0","")):
            count -=1

print(count)