from sys import stdin
import bisect


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

li = [7,5,3]
point = 0

for i in range(n+1):
    s = str(i)
    if s.count("7") > 0 and s.count("5") > 0 and s.count("3") > 0:
        point += 1

print(point)