A = list(map(int,list(input())))
N = len(A)
K = int(input())
dp = [[[[0 for _ in range(100)]] for _ in range(2)] for _ in range(N+1)]
dp[1][0][1] = 1
for i in range(2,N+1):
    for j in range(100):
        dp[i][1][j] = dp[i-1][1][j-1]*9
        if A[i-1]==0:
            dp[i][0][j] = dp[i-1][0][j]
        else:
            dp[i][0][j] = dp[i-1][0][j-1]
            dp[i][1][j] += dp[i-1][0][j-1]*(A[i-1]-1)*(A[i-1]>1)+dp[i-1][0][j]*(A[i-1]==1)
print(dp[N][0][K]+dp[N][1][K])