def digit_counter(number):
  count = 0
  while number > 0:
    a = number % 10
    if a != 0:
      count += 1
  	number //= 10
return count

num = int(input())
k = int(input())
for j in range(1, num):
	if digit_counter(j) == k:
  		count += 1
print(count)