a = int(input())
b = int(input())

import math
q = len(str(a))-1

e = 9**b * math.factorial(q) // math.factorial(q-b)

for i in range(10**q, a+1):
  r = str(i)
  if len(r) - r.count("0") == b:
    e += 1
    
print(e)