import itertools

import bisect



lis = list(itertools.product('7530',repeat = 9))

int_lis = list(map(int,list(map(''.join,lis))))

str_lis = list(map(str,int_lis[:-16]))

lis = []

for s in str_lis:

    if ('7' in s) and ('5' in s) and ('3' in s) and ('0' not in s) :

        lis.append(int(s))

print((bisect.bisect_right(sorted(lis),int(eval(input())))))

import itertools,bisect



num_list = []

def toInt(arr):

    num = int(''.join(arr))

for i in range(3,10):

    num_list += list(itertools.product('753',repeat=i) )

num = []

for nm in num_list:

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

        num.append(int(''.join(nm)))

num.sort()



print((bisect.bisect_right(num,int(eval(input())))))

import itertools
import bisect

lis = list(itertools.product("7530", repeat=9))
int_lis = list(map(int, list(map("".join, lis))))
str_lis = list(map(str, int_lis[:-16]))
lis = []
for s in str_lis:
    if ("7" in s) and ("5" in s) and ("3" in s) and ("0" not in s):
        lis.append(int(s))
print((bisect.bisect_right(sorted(lis), int(eval(input())))))

import itertools, bisect

num_list = []


def toInt(arr):
    num = int("".join(arr))


for i in range(3, 10):
    num_list += list(itertools.product("753", repeat=i))
num = []
for nm in num_list:
    if "3" in nm and "5" in nm and "7" in nm:
        num.append(int("".join(nm)))
num.sort()
print((bisect.bisect_right(num, int(eval(input())))))

-import itertools -import bisect +import itertools, bisect -lis = list(itertools.product("7530", repeat=9)) -int_lis = list(map(int, list(map("".join, lis)))) -str_lis = list(map(str, int_lis[:-16])) -lis = [] -for s in str_lis: -    if ("7" in s) and ("5" in s) and ("3" in s) and ("0" not in s): -        lis.append(int(s)) -print((bisect.bisect_right(sorted(lis), int(eval(input()))))) +num_list = [] + + +def toInt(arr): +    num = int("".join(arr)) + + +for i in range(3, 10): +    num_list += list(itertools.product("753", repeat=i)) +num = [] +for nm in num_list: +    if "3" in nm and "5" in nm and "7" in nm: +        num.append(int("".join(nm))) +num.sort() +print((bisect.bisect_right(num, int(eval(input())))))