from itertools import product

n = int(eval(input()))

A = set()

for x in product('753_', repeat=9):

    s = ''.join(x).replace('_', '')

    if all(d in s for d in '753') and int(s) <= n:

        A.add(s)

print((len(A)))
n = int(eval(input()))

B = []

def dfs(A):

  x = int(''.join(A))

  if x <= n:

    if '7' in A and '5' in A and '3' in A:

      B.append(x)

    dfs(A + ['7'])

    dfs(A + ['5'])

    dfs(A + ['3'])



dfs(['0'])

print((len(B)))
from itertools import product

n = int(eval(input()))
A = set()
for x in product("753_", repeat=9):
    s = "".join(x).replace("_", "")
    if all(d in s for d in "753") and int(s) <= n:
        A.add(s)
print((len(A)))

n = int(eval(input()))
B = []


def dfs(A):
    x = int("".join(A))
    if x <= n:
        if "7" in A and "5" in A and "3" in A:
            B.append(x)
        dfs(A + ["7"])
        dfs(A + ["5"])
        dfs(A + ["3"])


dfs(["0"])
print((len(B)))

-from itertools import product +n = int(eval(input())) +B = [] -n = int(eval(input())) -A = set() -for x in product("753_", repeat=9): -    s = "".join(x).replace("_", "") -    if all(d in s for d in "753") and int(s) <= n: -        A.add(s) -print((len(A))) + +def dfs(A): +    x = int("".join(A)) +    if x <= n: +        if "7" in A and "5" in A and "3" in A: +            B.append(x) +        dfs(A + ["7"]) +        dfs(A + ["5"]) +        dfs(A + ["3"]) + + +dfs(["0"]) +print((len(B)))