n = int(input())
k = int(input())
counter = 0
for num in range(n+1):
    nonzero = 0
    for i in str(num):
        if i != "0":
            nonzero += 1
    if nonzero == k:
        counter += 1
print(counter)