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 x == "":

		continue

	elif len(set(x)) < 3:

		continue

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

		A.add(int(x))

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

n = int(eval(input()))

cnt = 0

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

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

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

			p = int("".join(p))

			if p <= 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 x == "":
        continue
    elif len(set(x)) < 3:
        continue
    elif int(x) not in A and int(x) <= n:
        A.add(int(x))
print((len(A)))

from itertools import product

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

-num = ["", "3", "5", "7"] -A = set() -for i in product(num, repeat=9): -    x = "".join(i) -    if x == "": -        continue -    elif len(set(x)) < 3: -        continue -    elif int(x) not in A and int(x) <= n: -        A.add(int(x)) -print((len(A))) +cnt = 0 +for i in range(3, len(str(n)) + 1): +    for p in product(["7", "5", "3"], repeat=i): +        if len(set(p)) == 3: +            p = int("".join(p)) +            if p <= n: +                cnt += 1 +print(cnt)