S = input()
N = len(S)
K = int(input())
def nCk(n, k):
    if n < k:
        return 0

    ans = 1
    for i in range(1, k+1):
        ans *= (n-i+1)
        ans //= i
    return ans

ans = 0
if K > N:
    print(ans) 
    exit()

for i in range(K):
    if int(S[i]) == 0:
        continue

    if i == K-1:
        ans += int(S[i])*9**(K-1-i)*nCk(N-1-i, K-1-i) + 9**(K-i)*nCk(N-1-i, K-i)
    else:
        ans += (int(S[i])-1)*9**(K-1-i)*nCk(N-1-i, K-1-i) + 9**(K-i)*nCk(N-1-i, K-i)

print(ans)