n=int(input())
k=int(input())
count=0
for i in range(10**(k-1),n+1):
  s=str(i)
  n=len(s)
  if k>1:
      if '0' not in s:
          #print(s)
          if n==k:
              count+=1
      else:
          if n-s.count('0')==k:
              count+=1
  else:
      if n-s.count('0')==k:
          count+=1
       
print(count)
        