num = int(input())
K = int(input())
www = 0
zzz = 0
yyy = 0
for x in range(num + 1):
  if x == 0:
    	continue
  numstr=str(x) 
  list_num = list(numstr)
  www = len(list_num)
  zzz = list_num.count("0")
  if K == (www - zzz):
  	yyy += 1
  else:
    continue
print(yyy)