N = int(eval(input()))



def dfs(s):

  if int(s) > N: return 0

  ret = 1 if all(s.count(c) > 0 for c in "753") else 0

  for c in "753":

    ret += dfs(s+c)

  return ret

print((dfs("0")))
import itertools

n = eval(input())

number = list("753")

N = []

flag = False

for i in range(3, 10):

  for v in itertools.product(number, repeat=i):

    if "7" in v and "5" in v and "3" in v:

      if int("".join(v)) <= int(n): N.append(int("".join(v)))

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


def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(s + c)
    return ret


print((dfs("0")))

import itertools

n = eval(input())
number = list("753")
N = []
flag = False
for i in range(3, 10):
    for v in itertools.product(number, repeat=i):
        if "7" in v and "5" in v and "3" in v:
            if int("".join(v)) <= int(n):
                N.append(int("".join(v)))
print((len(N)))

-N = int(eval(input())) +import itertools - -def dfs(s): -    if int(s) > N: -        return 0 -    ret = 1 if all(s.count(c) > 0 for c in "753") else 0 -    for c in "753": -        ret += dfs(s + c) -    return ret - - -print((dfs("0"))) +n = eval(input()) +number = list("753") +N = [] +flag = False +for i in range(3, 10): +    for v in itertools.product(number, repeat=i): +        if "7" in v and "5" in v and "3" in v: +            if int("".join(v)) <= int(n): +                N.append(int("".join(v))) +print((len(N)))