 N = int(input())
K = int(input())

count = 0

for i in range(1, N + 1):
  s = str(i)
  count_len = len(s)
  count_zero = s.count('0')
  count_not0 = count_len - count_zero
  if (count_not0 == K):
    count += 1

print(count)