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

total_count = 0

for i in range(n):
    count = 0
    tmp = i + 1
    # print("i = {}".format(i + 1))
    while tmp >= 1:
        if (tmp % 10 != 0):
            count = count + 1
        tmp = tmp // 10
    if (count == k):
        total_count = total_count + 1

print(total_count)
