def f(N, K):

    M, R = N // 10, N % 10

    if K == 0:

        return 1

    elif M == 0 and K == 1:

        return R

    elif M == 0 and K != 1:

        return 0

    else:

        return R * f(M, K-1) + (9-R) * f(M-1, K-1) + f(M, K)





N = int(eval(input()))

K = int(eval(input()))

print((f(N, K)))

def DP(n, k):

    if k == 0:

        return 1

    elif n < 10 and k == 1:

        return n

    elif n < 10 and k != 0:

        return 0

    else:

        q, r = n//10, n % 10

        return DP(q, k)+r*DP(q, k-1)+(9-r)*DP(q-1, k-1)





n = int(eval(input()))

k = int(eval(input()))

print((DP(n, k)))

def f(N, K):
    M, R = N // 10, N % 10
    if K == 0:
        return 1
    elif M == 0 and K == 1:
        return R
    elif M == 0 and K != 1:
        return 0
    else:
        return R * f(M, K - 1) + (9 - R) * f(M - 1, K - 1) + f(M, K)


N = int(eval(input()))
K = int(eval(input()))
print((f(N, K)))

def DP(n, k):
    if k == 0:
        return 1
    elif n < 10 and k == 1:
        return n
    elif n < 10 and k != 0:
        return 0
    else:
        q, r = n // 10, n % 10
        return DP(q, k) + r * DP(q, k - 1) + (9 - r) * DP(q - 1, k - 1)


n = int(eval(input()))
k = int(eval(input()))
print((DP(n, k)))

-def f(N, K): -    M, R = N // 10, N % 10 -    if K == 0: +def DP(n, k): +    if k == 0: -    elif M == 0 and K == 1: -        return R -    elif M == 0 and K != 1: +    elif n < 10 and k == 1: +        return n +    elif n < 10 and k != 0: -        return R * f(M, K - 1) + (9 - R) * f(M - 1, K - 1) + f(M, K) +        q, r = n // 10, n % 10 +        return DP(q, k) + r * DP(q, k - 1) + (9 - r) * DP(q - 1, k - 1) -N = int(eval(input())) -K = int(eval(input())) -print((f(N, K))) +n = int(eval(input())) +k = int(eval(input())) +print((DP(n, k)))