n = int(input())
k = int(input())

num_list = []

c = 0

for i in range(n):
    temp = list(str(i + 1))
    num_0 = temp.count("0")
    non_0 = len(temp) - num_0
    if non_0 == k:
        c = c + 1

        
print(c)