N = input()
K = input()

def check(n):
  m = 0
  for i in range(len('n')):
    if str(n)[i] != '0'
      m = m + 1
    else:
      continue
  if m == K:
    return 1
  else:
    return 0

def count(n):
  return count(n - 1) + check(n -1)

print(count(N))