S = input()
N = len(S)
K = int(input())
def nCk(n, k):
    ans = 1
    for i in range(1, k+1):
        ans *= (n-i+1)
        ans //= i
    return ans

ans = 1
for i in range(K):
    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)