su = 0
m = int(input())
nonZeros = int(input())
for i in range(1,m +1):
    num = i
    currNonZeros = 0
    while(num!=0):
    	if num % 10 != 0:
   		    currNonZeros += 1
    	num = int(num/10)
    if currNonZeros == nonZeros:
    	su += 1
print(su)
    