# your code goes here
max = int(input())
num = 0
count = 0
testNum = 0
for n in range(0,max):
	cnt = 0
	for n in range (0,len(str(testNum))):
		num = int(str(testNum)[cnt])
		if num == 7 or num == 5 or num == 3:
			cnt = cnt+1
		else:
			break
		if cnt+1 == len(str(testNum)):
			count = count +1
		testNum = testNum + 1
		
print(count)