def f(n):
if n>20:
return n ** 3 + n
elif n <=20 and n%2==0:
return 3 * f(n+1) + f(n+3)
else:
return f(n+2) + 2 * f(n+3)
badcount = 0
count = 0
for i in range(1, 1001):
t = f(i)
while t>0 or badcount !=0:
if t % 10 == 1:
badcount += 1
t = t // 10
if badcount == 0:
count += 1
print(count)