from itertools import *

N = int(eval(input()))

ans = 0



for i in product("0357",repeat=10):

  j = "".join(i)

  if "0" not in str(int(j)) and "3" in j and "5" in j and "7" in j and int(j)<=N:

    ans+=1



print(ans)
from itertools import *

N = int(eval(input()))

S = []

ans = 0



for n in range(10):

  S+=list(product("357",repeat=n))



for s in S:

  if len(set(s))==3 and int("".join(s))<=N:

    ans+=1



print(ans)
from itertools import *

N = int(eval(input()))
ans = 0
for i in product("0357", repeat=10):
    j = "".join(i)
    if "0" not in str(int(j)) and "3" in j and "5" in j and "7" in j and int(j) <= N:
        ans += 1
print(ans)

from itertools import *

N = int(eval(input()))
S = []
ans = 0
for n in range(10):
    S += list(product("357", repeat=n))
for s in S:
    if len(set(s)) == 3 and int("".join(s)) <= N:
        ans += 1
print(ans)

+S = [] -for i in product("0357", repeat=10): -    j = "".join(i) -    if "0" not in str(int(j)) and "3" in j and "5" in j and "7" in j and int(j) <= N: +for n in range(10): +    S += list(product("357", repeat=n)) +for s in S: +    if len(set(s)) == 3 and int("".join(s)) <= N: