N = int(input())
K = int(input())

if K == 1:
    n = 0
elif K == 2:
    n = 10
else:
    n = 100

count = 0
for i in range(n, N+1):
    check = 0
    for s in str(i):
        if s != '0':
            check += 1
    if check == K:
        count += 1

print(count)