def getNum(num):
  lst = str(num)
  return len(lst) - lst.count('0')

n = int(input())
k = int(input())
start = int('1'*k)
count = 0

for i in range(start,n+1):
  if getNum(i) == k:
    count += 1

print(count)