from scipy.special import comb
N = input()
K = int(input())

ans = 0
for k in range(K):
    n = N[k:]
    L = len(n)
    s = K-k
    #0
    ans += comb(L-1,s)*(9**(s))
    #1~N[0]-1
    if s-1 > 0:
        ans += (int(N[0])-1)*comb(L-1,s-1)*(9**(s-1))
    #N[0]
ans += int(N[K-1])
print(int(ans))

