N = input()
K = int(input())

def c(i, j):
    i, j = i-1, j-1
    if j == 0:
        return 1
    r = 1
    for k in range(j):
        r *= (i-k) / (j-k)
    return int(r)


def d(n):
    if K == 1:
        return int(N[0])
    if K == 3:
        return (int(N[0])-1)*9**2 + int(N[1]) * int(N[2])
    if K == 2:
        return (int(N[0])-1) * 9 + int(N[1])


ans = 0
l = len(N)
for i in range(K, l+1):
    if i == l:
        print((c(i,K)-1)*int(N[0])*9**(K-1))
        ans += (c(i, K)-1)*int(N[0])*9**(K-1) + d(N)
    else:
        ans += c(i, K) * 9**K
    
print(ans)
        
    