N = int(eval(input()))

M = len(str(N))

count = 0



def dfs(A):

  global count

  

  if len(A) <= M and (3 in A and 5 in A and 7 in A):

    num = 0

    for i in range(len(A)):

      num += A[i]*(10**i)

    if num <= N:

      count += 1

  elif len(A) > M:

    return



  for i in [3, 5, 7]:

    A.append(i)

    dfs(A)

    A.pop()

  

dfs([])

print(count)

    
def func(cur, use):

  

  global counter

  if (cur > N): return 

  if (use == 0b111): counter += 1



  func(cur * 10 + 7, use | 0b001)

  func(cur * 10 + 5, use | 0b010)

  func(cur * 10 + 3, use | 0b100) 



N = int(eval(input()))

counter = 0

func(0, 0)

print(counter)
N = int(eval(input()))
M = len(str(N))
count = 0


def dfs(A):
    global count
    if len(A) <= M and (3 in A and 5 in A and 7 in A):
        num = 0
        for i in range(len(A)):
            num += A[i] * (10**i)
        if num <= N:
            count += 1
    elif len(A) > M:
        return
    for i in [3, 5, 7]:
        A.append(i)
        dfs(A)
        A.pop()


dfs([])
print(count)

def func(cur, use):
    global counter
    if cur > N:
        return
    if use == 0b111:
        counter += 1
    func(cur * 10 + 7, use | 0b001)
    func(cur * 10 + 5, use | 0b010)
    func(cur * 10 + 3, use | 0b100)


N = int(eval(input()))
counter = 0
func(0, 0)
print(counter)

-N = int(eval(input())) -M = len(str(N)) -count = 0 +def func(cur, use): +    global counter +    if cur > N: +        return +    if use == 0b111: +        counter += 1 +    func(cur * 10 + 7, use | 0b001) +    func(cur * 10 + 5, use | 0b010) +    func(cur * 10 + 3, use | 0b100) -def dfs(A): -    global count -    if len(A) <= M and (3 in A and 5 in A and 7 in A): -        num = 0 -        for i in range(len(A)): -            num += A[i] * (10**i) -        if num <= N: -            count += 1 -    elif len(A) > M: -        return -    for i in [3, 5, 7]: -        A.append(i) -        dfs(A) -        A.pop() - - -dfs([]) -print(count) +N = int(eval(input())) +counter = 0 +func(0, 0) +print(counter)