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

m = len(N)
ans = 1
for i in range(K):
    ans = (ans*(m-i)*9)//(K-i)
count = K
i = 0

while count and i < m:
    Num = 9-int(N[i])
    for j in range(count-1):
        Num = (Num*(m-1-i-j)*9)//(count-1-j)
    ans -= Num
    # print(Num,i,j,count)
    if int(N[i]) != 0:
        count -= 1
    i += 1

print(ans)
