import math
N = int(input())
l = len(str(N))
K = int(input())
if l>=K:
    t = (math.factorial(l) // (math.factorial(l-K) * math.factorial(K)))*(9**K)
    t2 = math.factorial(l-1) // (math.factorial(l-K) * math.factorial(K-1))
    t2 = t2*(9-int(str(N)[0]))*(9**(K-1))
    print(t-t2)
else:
    print(0)