import sys

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

if len(N) < K:
    print(0)
    sys.exit()

ans = 0

for i in range(K, len(N)+1):
    bc = 1
    for j in range(K-1):
        bc *= i-(j+1)
    if K-1 != 0:
        bc //= K-1
    else:
        bc = 1
    nonzero = (9**K)*bc
    ans += nonzero

if K == 1:
    ans -= 9-int(N[0])
elif K == 2:
    ans -= (9-int(N[0]))*(len(N)-1)*9
    ans -= 9-int(N[1])
else: # K==3
    ans -= (9-int(N[0]))*((len(N)-1)*(len(N)-2)//2)*81
    ans -= (9-int(N[1]))*(len(N)-2)*9
    ans -= 9-int(N[2])

if ans < 0:
    ans = 0

zero = 0
for i in range(len(N)):
    if N[i] == 0:
        zero += 1

if zero > 3:
    ans = 0
    for i in range(K, len(N)):
        bc = 1
        for j in range(K-1):
            bc *= i-(j+1)
        if K-1 != 0:
            bc //= K-1
        else:
            bc = 1
        nonzero = (9**K)*bc
        ans += nonzero

print(ans)