import math
n = int(input())
n2 = str(n)
def permutations_count(n, r):
  return math.factorial(n) // math.factorial(n - r)//math.factorial(r)
k = int(input())
x = 0
for i in range(k,len(n2)+1):
  if i != len(n2):
    x += 9 * 9**(k-1) * permutations_count(i-1,k-1)
  else:
    if k == 1:
      x += int(n2[0])
    elif k == 2:
      x += 1 * (int(n2[1])+9*(i-2)) + (int(n2[0])-1) * 9 * (i-1)
    elif k == 3:
      x += 1*1*(int(n2[2])+9*(i-3))+1*((int(n2[1])-1)*9*(i-2)+1*9*9*permutations_count(i-2,2))+(int(n2[0])-1)*9*9*permutations_count(i-1,2)
print(x)