from bisect import bisect_left

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

temp_dict = {}
for i in range(1, k + 1):
    temp_dict[i] = []

flag = True
d = 0
while flag:
    base = 10 ** d
    for i in range(1, 10):
        num = i * base
        if num > n:
            flag = False
            break
        temp_dict[1].append(num)

        for j in range(1, k):
            l = bisect_left(temp_dict[j], base)
            temp_list = [num + temp for temp in temp_dict[j][:l] if num + temp <= n]
            temp_dict[j + 1].extend(temp_list)
    d += 1

ans = len(temp_dict[k])
print(ans)