def Pika(p,K):
    tmp = 1
    now = p
    for i in range(K):
        tmp *= now
        now -= 1
    now = 1
    for i in range(K):
        tmp //= now
        now += 1
    tmp *= 9**K
    return tmp

N = input()
K = int(input())
p = len(N)
def solve(N,K,p):
    if K==0:
        return 1
    elif N=='':
        return 0
    elif N[0]=='0':
        return solve(N[1:],K,p)
    else:
        ans = 0
        ans += Pika(p-1,K)
        atama = int(N[0])
        ans += (atama-1)*Pika(p-1,K-1)
        
        ans += solve(N[1:],K-1,p-1)
    
    return ans
A = solve (N,K,p)
print(A)