from sys import stdin

n = int(stdin.readline().rstrip())

ans = 0

for i in range(n):
    if str(i) in "7" and str(i) in "5" and str(i) in "3":
        if not str(i) in ["1", "2", "4", "6", "8", "9"]:
            ans += 1

print(ans)