from scipy.misc import comb
N = int(input())
K = int(input())
n = len(str(N))
ans = comb(n - 1, K) * 9 ** K
for i in range(K):
    ans += comb(n - 1 - i, K - 1 - i) * 9 ** (K - 1 - i) * (int(str(N)[i]) - 1)
    ans += comb(n - 1 - i, K - 2 - i) * 9 ** (K - 1 - i) * (int(str(N)[i + 1]) - 1)

 
print(ans + 1)