def nCk(n, k):
    if n < k:
        return 0
    elif k == 0:
        return 1
    elif k == 1:
        return n
    elif k == 2:
        return n * (n - 1) // 2
    else:
        return n * (n - 1) * (n - 2) // 6


def solve(N, K):
    if K == 0:
        return 1

    M = len(N)
    if M < K:
        return 0

    res = solve(N[1:], K - 1)
    res += (int(N[0]) - 1) * nCk(M - 1, K - 1) * (9 ** (K - 1))
    res += nCk(M - 1, K) * (9 ** K)

    return res


N = input()
K = int(input())

print(solve(N, K))