import itertools

n = eval(input())

number = list("753")

N = []

flag = False

for i in range(3, 10):

  for v in itertools.product(number, repeat=i):

    if "7" in v and "5" in v and "3" in v:

      if int("".join(v)) <= int(n): N.append(int("".join(v)))

print((len(N)))
import itertools

n = int(eval(input()))

cnt = 0

for i in range(3,len(str(n))+1):

    for v in itertools.product(["3","5","7"], repeat=i):

        if len(set(v))!=3: continue

        x = int("".join(v))

        if n >= x: cnt += 1



print(cnt)
import itertools

n = eval(input())
number = list("753")
N = []
flag = False
for i in range(3, 10):
    for v in itertools.product(number, repeat=i):
        if "7" in v and "5" in v and "3" in v:
            if int("".join(v)) <= int(n):
                N.append(int("".join(v)))
print((len(N)))

import itertools

n = int(eval(input()))
cnt = 0
for i in range(3, len(str(n)) + 1):
    for v in itertools.product(["3", "5", "7"], repeat=i):
        if len(set(v)) != 3:
            continue
        x = int("".join(v))
        if n >= x:
            cnt += 1
print(cnt)

-n = eval(input()) -number = list("753") -N = [] -flag = False -for i in range(3, 10): -    for v in itertools.product(number, repeat=i): -        if "7" in v and "5" in v and "3" in v: -            if int("".join(v)) <= int(n): -                N.append(int("".join(v))) -print((len(N))) +n = int(eval(input())) +cnt = 0 +for i in range(3, len(str(n)) + 1): +    for v in itertools.product(["3", "5", "7"], repeat=i): +        if len(set(v)) != 3: +            continue +        x = int("".join(v)) +        if n >= x: +            cnt += 1 +print(cnt)