from itertools import product

n = int(eval(input()))

num = ['','3','5','7']

A = set() 

for i in product(num,repeat=9):

    x = "".join(i)

    if len(set(x)) == 3:

        if (int(x) not in A) and (int(x) <= n):

            A.add(int(x))

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

num = ['3','5','7']

for i in range(len(str(N))-1):

    num2 = []

    for n in num:

        num2.append(n+'3')

        num2.append(n+'5')

        num2.append(n+'7')

        num2.append(n)

    num = num2

cnt = 0

num = set(num)

for n in num:

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

        if int(n) <= N:

            cnt += 1

print(cnt)
from itertools import product

n = int(eval(input()))
num = ["", "3", "5", "7"]
A = set()
for i in product(num, repeat=9):
    x = "".join(i)
    if len(set(x)) == 3:
        if (int(x) not in A) and (int(x) <= n):
            A.add(int(x))
print((len(A)))

N = int(eval(input()))
num = ["3", "5", "7"]
for i in range(len(str(N)) - 1):
    num2 = []
    for n in num:
        num2.append(n + "3")
        num2.append(n + "5")
        num2.append(n + "7")
        num2.append(n)
    num = num2
cnt = 0
num = set(num)
for n in num:
    if "3" in n and "5" in n and "7" in n:
        if int(n) <= N:
            cnt += 1
print(cnt)

-from itertools import product - -n = int(eval(input())) -num = ["", "3", "5", "7"] -A = set() -for i in product(num, repeat=9): -    x = "".join(i) -    if len(set(x)) == 3: -        if (int(x) not in A) and (int(x) <= n): -            A.add(int(x)) -print((len(A))) +N = int(eval(input())) +num = ["3", "5", "7"] +for i in range(len(str(N)) - 1): +    num2 = [] +    for n in num: +        num2.append(n + "3") +        num2.append(n + "5") +        num2.append(n + "7") +        num2.append(n) +    num = num2 +cnt = 0 +num = set(num) +for n in num: +    if "3" in n and "5" in n and "7" in n: +        if int(n) <= N: +            cnt += 1 +print(cnt)