N = int(eval(input()))

K = int(eval(input()))



def solve(n,k):

    if k==0: return 1

    if n < 10:

        return n if k==1 else 0

    if n < 100 and k == 3:

        return 0

    m,d = divmod(n,10)

    ret = d * solve(m,k-1)

    ret += (9-d)*solve(m-1,k-1)

    ret += solve(m,k)

    return ret



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

L = len(N)

K = int(eval(input()))



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

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

for i,c in enumerate(N):

    c = int(c)

    for k in range(K+1):

        for less in range(2):

            for d in range(10):

                nk = k + (d>0)

                if nk > K: continue

                if less == 0 and d > c: continue

                nxless = not(less==0 and d==c)

                dp[i+1][nk][nxless] += dp[i][k][less]

print((sum(dp[-1][-1])))
N = int(eval(input()))
K = int(eval(input()))


def solve(n, k):
    if k == 0:
        return 1
    if n < 10:
        return n if k == 1 else 0
    if n < 100 and k == 3:
        return 0
    m, d = divmod(n, 10)
    ret = d * solve(m, k - 1)
    ret += (9 - d) * solve(m - 1, k - 1)
    ret += solve(m, k)
    return ret


print((solve(N, K)))

N = eval(input())
L = len(N)
K = int(eval(input()))
dp = [[[0] * 2 for _ in range(K + 1)] for _ in range(L + 1)]
dp[0][0][0] = 1
for i, c in enumerate(N):
    c = int(c)
    for k in range(K + 1):
        for less in range(2):
            for d in range(10):
                nk = k + (d > 0)
                if nk > K:
                    continue
                if less == 0 and d > c:
                    continue
                nxless = not (less == 0 and d == c)
                dp[i + 1][nk][nxless] += dp[i][k][less]
print((sum(dp[-1][-1])))

-N = int(eval(input())) +N = eval(input()) +L = len(N) - - -def solve(n, k): -    if k == 0: -        return 1 -    if n < 10: -        return n if k == 1 else 0 -    if n < 100 and k == 3: -        return 0 -    m, d = divmod(n, 10) -    ret = d * solve(m, k - 1) -    ret += (9 - d) * solve(m - 1, k - 1) -    ret += solve(m, k) -    return ret - - -print((solve(N, K))) +dp = [[[0] * 2 for _ in range(K + 1)] for _ in range(L + 1)] +dp[0][0][0] = 1 +for i, c in enumerate(N): +    c = int(c) +    for k in range(K + 1): +        for less in range(2): +            for d in range(10): +                nk = k + (d > 0) +                if nk > K: +                    continue +                if less == 0 and d > c: +                    continue +                nxless = not (less == 0 and d == c) +                dp[i + 1][nk][nxless] += dp[i][k][less] +print((sum(dp[-1][-1])))