N = input()
L = len(N)
K = int(input())


def main(d, k):
    if d == L:
        if k == 0:
            return 1
        else:
            return 0
    if N[d] == "0":
        return main(d + 1, k)
    if (L - d) < k:
        return 0
    return main1(d+1, k)+main1(d+1, k-1)*(int(N[d])-1)+main(d+1, k-1)


def main1(d, k):
    if k == 0:
        return 1
    if d == L:
        return 0
    return main1(d+1, k-1)*9+main1(d+1, k)


print(main(0, K))
