from itertools import product

n = int(eval(input()))

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



x =[]

for i in range(3,11):

    x += list(product(a, repeat = i))

y = []

for j in x:

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

        y.append(j)

z = []

for k in range(len(y)):

    z.append(''.join(y[k]))

z = [int(_) for _ in z]



b = 0

for p in z:

    if p <= n:

        b += 1



print(b)

from itertools import product

l = []

for _ in range(3,10):

    tmp = list(product('753', repeat = _))

    l += tmp



m = []

for i in l:

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

       m.append(int(''.join(i)))



n = int(eval(input()))

ans = 0

for j in m:

    if j <= n:

        ans += 1



print(ans)
from itertools import product

n = int(eval(input()))
a = ["7", "5", "3"]
x = []
for i in range(3, 11):
    x += list(product(a, repeat=i))
y = []
for j in x:
    if "7" in j and "5" in j and "3" in j:
        y.append(j)
z = []
for k in range(len(y)):
    z.append("".join(y[k]))
z = [int(_) for _ in z]
b = 0
for p in z:
    if p <= n:
        b += 1
print(b)

from itertools import product

l = []
for _ in range(3, 10):
    tmp = list(product("753", repeat=_))
    l += tmp
m = []
for i in l:
    if len(set(i)) == 3:
        m.append(int("".join(i)))
n = int(eval(input()))
ans = 0
for j in m:
    if j <= n:
        ans += 1
print(ans)

+l = [] +for _ in range(3, 10): +    tmp = list(product("753", repeat=_)) +    l += tmp +m = [] +for i in l: +    if len(set(i)) == 3: +        m.append(int("".join(i))) -a = ["7", "5", "3"] -x = [] -for i in range(3, 11): -    x += list(product(a, repeat=i)) -y = [] -for j in x: -    if "7" in j and "5" in j and "3" in j: -        y.append(j) -z = [] -for k in range(len(y)): -    z.append("".join(y[k])) -z = [int(_) for _ in z] -b = 0 -for p in z: -    if p <= n: -        b += 1 -print(b) +ans = 0 +for j in m: +    if j <= n: +        ans += 1 +print(ans)