import numpy as np
n=input()
k=int(input())
dp=np.zeros((len(n)+1,k+1,2))
dp[0][0][0]=1
for i in range(1,len(n)+1):
    for j in range(int(n[i-1])):
        if j==0:
            dp[i][1]+=dp[i-1][0]
        else:
            dp[i][1][1:]+=dp[i-1][0][:-1]
    for j in range(10):
        if j==0:
            dp[i][1]+=dp[i-1][1]
        else:
            dp[i][1][1:]+=dp[i-1][1][:-1]
    if int(n[i-1])==0:
        dp[i][0]+=dp[i-1][0]
    else:
        dp[i][0][1:]+=dp[i-1][0][:-1]
print(dp[-1][0][-1]+dp[-1][1][-1])
