def check(n):
  tmp = str(n)
  count = 0
  for i in range(len(tmp)):
    if tmp[i] != "0":
      count+=1
  return count

n = int(input())
k = int(input())
count = 0

for i in range(n+1):
  tmp = check(i)
  if tmp == k:
    count+=1
print(count)
    