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

num_list = []

c = 0

for i in range(n):
    num_list.append(str(i+1))



for j in range(n):
    temp = list(num_list[j])
    num_0 = temp.count("0")
    non_0 = len(temp) - num_0
    if non_0 == k:
        c = c + 1
        
print(c)