n = int(input())
k = int(input())

total = 0
for i in range(1,n+1):
  s = str(i)
  cnt = 0
  for c in s:
    if c != '0':
      cnt += 1
    if cnt > k:
      break
  if cnt == k:
    total += 1
print(total)