n = eval(input())

k = int(eval(input()))



dp = [[[0,0] for i in range(len(n)+1)] for j in range(len(n)+1)]



# print(dp)

num_d = len(n)



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



for i in range(len(n)):

    num = int(n[i])



    if num == 0:

        for j in range(num_d):

            dp[i+1][j+1][0] = dp[i][j][0]

            dp[i+1][j+1][1] += dp[i][j][1]



        for j in range(num_d+1):

            dp[i+1][j][1] += dp[i][j][1]*9



    else:

        for j in range(num_d):

            dp[i+1][j][0] = dp[i][j][0]



        for j in range(num_d+1):

            dp[i+1][j][1] += dp[i][j][0]*(num-1)

            dp[i+1][j][1] += dp[i][j][1]*9



        for j in range(num_d):

            dp[i+1][j+1][1] += dp[i][j][0] + dp[i][j][1]



# print(dp[-1])

if num_d < k:

    print((0))

else:

    print((sum(dp[-1][num_d-k])))
N = eval(input())

K = int(eval(input()))

m = len(N)

dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]

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



for i in range(1, m + 1):

    l = int(N[i - 1])

    for k in range(K + 1):

        dp[i][1][k] += dp[i - 1][1][k]

        if l != 0:

            dp[i][1][k] += dp[i - 1][0][k]

        else:

            dp[i][0][k] += dp[i - 1][0][k]

        if k - 1 >= 0:

            dp[i][1][k] += 9 * dp[i - 1][1][k - 1]

            if l != 0:

                dp[i][0][k] += dp[i - 1][0][k - 1]

                dp[i][1][k] += (l - 1) * dp[i - 1][0][k - 1]



print((dp[m][0][K] + dp[m][1][K]))
n = eval(input())
k = int(eval(input()))
dp = [[[0, 0] for i in range(len(n) + 1)] for j in range(len(n) + 1)]
# print(dp)
num_d = len(n)
dp[0][0][0] = 1
for i in range(len(n)):
    num = int(n[i])
    if num == 0:
        for j in range(num_d):
            dp[i + 1][j + 1][0] = dp[i][j][0]
            dp[i + 1][j + 1][1] += dp[i][j][1]
        for j in range(num_d + 1):
            dp[i + 1][j][1] += dp[i][j][1] * 9
    else:
        for j in range(num_d):
            dp[i + 1][j][0] = dp[i][j][0]
        for j in range(num_d + 1):
            dp[i + 1][j][1] += dp[i][j][0] * (num - 1)
            dp[i + 1][j][1] += dp[i][j][1] * 9
        for j in range(num_d):
            dp[i + 1][j + 1][1] += dp[i][j][0] + dp[i][j][1]
# print(dp[-1])
if num_d < k:
    print((0))
else:
    print((sum(dp[-1][num_d - k])))

N = eval(input())
K = int(eval(input()))
m = len(N)
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp[0][0][0] = 1
for i in range(1, m + 1):
    l = int(N[i - 1])
    for k in range(K + 1):
        dp[i][1][k] += dp[i - 1][1][k]
        if l != 0:
            dp[i][1][k] += dp[i - 1][0][k]
        else:
            dp[i][0][k] += dp[i - 1][0][k]
        if k - 1 >= 0:
            dp[i][1][k] += 9 * dp[i - 1][1][k - 1]
            if l != 0:
                dp[i][0][k] += dp[i - 1][0][k - 1]
                dp[i][1][k] += (l - 1) * dp[i - 1][0][k - 1]
print((dp[m][0][K] + dp[m][1][K]))

-n = eval(input()) -k = int(eval(input())) -dp = [[[0, 0] for i in range(len(n) + 1)] for j in range(len(n) + 1)] -# print(dp) -num_d = len(n) +N = eval(input()) +K = int(eval(input())) +m = len(N) +dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)] -for i in range(len(n)): -    num = int(n[i]) -    if num == 0: -        for j in range(num_d): -            dp[i + 1][j + 1][0] = dp[i][j][0] -            dp[i + 1][j + 1][1] += dp[i][j][1] -        for j in range(num_d + 1): -            dp[i + 1][j][1] += dp[i][j][1] * 9 -    else: -        for j in range(num_d): -            dp[i + 1][j][0] = dp[i][j][0] -        for j in range(num_d + 1): -            dp[i + 1][j][1] += dp[i][j][0] * (num - 1) -            dp[i + 1][j][1] += dp[i][j][1] * 9 -        for j in range(num_d): -            dp[i + 1][j + 1][1] += dp[i][j][0] + dp[i][j][1] -# print(dp[-1]) -if num_d < k: -    print((0)) -else: -    print((sum(dp[-1][num_d - k]))) +for i in range(1, m + 1): +    l = int(N[i - 1]) +    for k in range(K + 1): +        dp[i][1][k] += dp[i - 1][1][k] +        if l != 0: +            dp[i][1][k] += dp[i - 1][0][k] +        else: +            dp[i][0][k] += dp[i - 1][0][k] +        if k - 1 >= 0: +            dp[i][1][k] += 9 * dp[i - 1][1][k - 1] +            if l != 0: +                dp[i][0][k] += dp[i - 1][0][k - 1] +                dp[i][1][k] += (l - 1) * dp[i - 1][0][k - 1] +print((dp[m][0][K] + dp[m][1][K]))