N=eval(input())

K=int(eval(input()))



def rec(N,K):

    if K==0:

        return 1#N以下の数で、0以外の数が０、すなわち残りの桁が全て０になるパターン



    if len(N)<K:

        return 0

    

    lsb=int(N[-1])



    if len(N)==1:

        return lsb

   

    return rec(N[:-1],K-1)*(lsb)+rec(str(int(N[:-1])-1),K-1)*(9-lsb)+rec(N[:-1],K)

    

print((rec(N,K)))
N=eval(input())

K=int(eval(input()))



dp=[[[0 for _ in range(K+2)] for _ in range(2)] for _ in range(len(N)+1)]



dp[0][0][0]=1



for i in range(len(N)):

    for smaller in range(2):

        for j in range(K+1):

            for x in range(10 if smaller==1 else int(N[i])+1):

                dp[i+1][smaller or (x < int(N[i]))][j+1 if x!=0 else j]+=dp[i][smaller][j]

print((dp[len(N)][1][K]+dp[len(N)][0][K]))
N = eval(input())
K = int(eval(input()))


def rec(N, K):
    if K == 0:
        return 1  # N以下の数で、0以外の数が０、すなわち残りの桁が全て０になるパターン
    if len(N) < K:
        return 0
    lsb = int(N[-1])
    if len(N) == 1:
        return lsb
    return (
        rec(N[:-1], K - 1) * (lsb)
        + rec(str(int(N[:-1]) - 1), K - 1) * (9 - lsb)
        + rec(N[:-1], K)
    )


print((rec(N, K)))

N = eval(input())
K = int(eval(input()))
dp = [[[0 for _ in range(K + 2)] for _ in range(2)] for _ in range(len(N) + 1)]
dp[0][0][0] = 1
for i in range(len(N)):
    for smaller in range(2):
        for j in range(K + 1):
            for x in range(10 if smaller == 1 else int(N[i]) + 1):
                dp[i + 1][smaller or (x < int(N[i]))][j + 1 if x != 0 else j] += dp[i][
                    smaller
                ][j]
print((dp[len(N)][1][K] + dp[len(N)][0][K]))

- - -def rec(N, K): -    if K == 0: -        return 1  # N以下の数で、0以外の数が０、すなわち残りの桁が全て０になるパターン -    if len(N) < K: -        return 0 -    lsb = int(N[-1]) -    if len(N) == 1: -        return lsb -    return ( -        rec(N[:-1], K - 1) * (lsb) -        + rec(str(int(N[:-1]) - 1), K - 1) * (9 - lsb) -        + rec(N[:-1], K) -    ) - - -print((rec(N, K))) +dp = [[[0 for _ in range(K + 2)] for _ in range(2)] for _ in range(len(N) + 1)] +dp[0][0][0] = 1 +for i in range(len(N)): +    for smaller in range(2): +        for j in range(K + 1): +            for x in range(10 if smaller == 1 else int(N[i]) + 1): +                dp[i + 1][smaller or (x < int(N[i]))][j + 1 if x != 0 else j] += dp[i][ +                    smaller +                ][j] +print((dp[len(N)][1][K] + dp[len(N)][0][K]))