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

def sum10ofject(x):
  count=0
  while x!=0:
    if x%10!=0:
      count+=1
    x=x//10
  return count
numcount=0
for i in range(n+1):
  if sum10ofject(i)==k:
    numcount+=1
print(numcount)