n = int(raw_input())
k = int(raw_input())
count = 0

for i in range(1, n + 1):
    non_zero = 0
    for j in str(i):
        if not j == '0':
             non_zero += 1
    if non_zero == k:
        count += 1

print count
