from scipy.special import comb

N = int(input())
K = int(input())
n = len(str(N))
m = list(map(int,str(N)))
A = (9 ** (K)) * comb(n-1,n-K-1,exact=True)
B = (m[0]-1) * (9 ** (K-1)) * comb(n-1,n-K,exact = True)
C = 0
if not n == K:
    for i in range(K):
        c_0 = (9 ** (K-1-i)) * comb(n-2-i,K-1-i,exact=True)
        c_9 = 1
        for j in range(1,i+1):
            c_9 *= m[j]
        c = c_0 * c_9
        C += c
else:
    c = 1
    for i in range(n-1):
        c *= m[i+1]
        C += c
print(A+B+C)