N = int(input())
K = int(input())
sN = str(N)
iN = list(map(int, sN[0:K]))
lN = len(sN)
sum = 0

if K == 1:
  	sum = iN[0] + (lN - 1) * 9
elif K == 2:
  	sum = iN[1] + (iN[0] - 1) * 9 + iN[0] * 9 * (lN - 2) + ((lN - 1) * (lN - 2) / 2) * 9 * 9
elif K == 3:
  	sum = iN[0] * iN[1] * (iN[2] + (lN - 3) * 9) + iN[0] * ((lN - 2) * (lN - 3) / 2) * 9 * 9 + ((lN - 1) * (lN - 2) * (lN - 3) / (3 * 2)) * 9 * 9 * 9

print(int(sum))