import numpy as np

s = eval(input())

n = int(s)



digit = len(s)



all_combinations = []



for i1 in ("3", "5", "7"):

    for i2 in ("3", "5", "7"):

        for i3 in ("3", "5", "7"):

            for i4 in ("3", "5", "7"):

                for i5 in ("3", "5", "7"):

                    for i6 in ("3", "5", "7"):

                        for i7 in ("3", "5", "7"):

                            for i8 in ("3", "5", "7"):

                                for i9 in ("3", "5", "7"):

                                    all_combinations.append(i1+i2+i3+i4+i5+i6+i7+i8+i9)



for i1 in ("3", "5", "7"):

    for i2 in ("3", "5", "7"):

        for i3 in ("3", "5", "7"):

            for i4 in ("3", "5", "7"):

                for i5 in ("3", "5", "7"):

                    for i6 in ("3", "5", "7"):

                        for i7 in ("3", "5", "7"):

                            for i8 in ("3", "5", "7"):

                                all_combinations.append(i1+i2+i3+i4+i5+i6+i7+i8)



for i1 in ("3", "5", "7"):

    for i2 in ("3", "5", "7"):

        for i3 in ("3", "5", "7"):

            for i4 in ("3", "5", "7"):

                for i5 in ("3", "5", "7"):

                    for i6 in ("3", "5", "7"):

                        for i7 in ("3", "5", "7"):

                            all_combinations.append(i1+i2+i3+i4+i5+i6+i7)



for i1 in ("3", "5", "7"):

    for i2 in ("3", "5", "7"):

        for i3 in ("3", "5", "7"):

            for i4 in ("3", "5", "7"):

                for i5 in ("3", "5", "7"):

                    for i6 in ("3", "5", "7"):

                        all_combinations.append(i1+i2+i3+i4+i5+i6)



for i1 in ("3", "5", "7"):

    for i2 in ("3", "5", "7"):

        for i3 in ("3", "5", "7"):

            for i4 in ("3", "5", "7"):

                for i5 in ("3", "5", "7"):

                    all_combinations.append(i1+i2+i3+i4+i5)



for i1 in ("3", "5", "7"):

    for i2 in ("3", "5", "7"):

        for i3 in ("3", "5", "7"):

            for i4 in ("3", "5", "7"):

                all_combinations.append(i1+i2+i3+i4)



for i1 in ("3", "5", "7"):

    for i2 in ("3", "5", "7"):

        for i3 in ("3", "5", "7"):

            all_combinations.append(i1+i2+i3)



selected_num = []

for i in all_combinations:

    if not ('7' in i):

        continue

    if not ('5' in i):

        continue

    if not ('3' in i):

        continue



    selected_num.append(int(i))



selected_num_array = np.array(selected_num)



print((np.sum(selected_num_array <= n)))
import numpy as np

from itertools import product

s = eval(input())

n = int(s)



digit = len(s)



selected_num = []

for order in range(3, 10, 1):

    for i in product('753', repeat = order):

        concat_str = "".join(i)

        if(('7' in concat_str) and ('5' in concat_str) and ('3' in concat_str)):

            selected_num.append(int(concat_str))



selected_num_array = np.array(selected_num)



print((np.sum(selected_num_array <= n)))
import numpy as np

s = eval(input())
n = int(s)
digit = len(s)
all_combinations = []
for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    for i6 in ("3", "5", "7"):
                        for i7 in ("3", "5", "7"):
                            for i8 in ("3", "5", "7"):
                                for i9 in ("3", "5", "7"):
                                    all_combinations.append(
                                        i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9
                                    )
for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    for i6 in ("3", "5", "7"):
                        for i7 in ("3", "5", "7"):
                            for i8 in ("3", "5", "7"):
                                all_combinations.append(
                                    i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8
                                )
for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    for i6 in ("3", "5", "7"):
                        for i7 in ("3", "5", "7"):
                            all_combinations.append(i1 + i2 + i3 + i4 + i5 + i6 + i7)
for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    for i6 in ("3", "5", "7"):
                        all_combinations.append(i1 + i2 + i3 + i4 + i5 + i6)
for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    all_combinations.append(i1 + i2 + i3 + i4 + i5)
for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                all_combinations.append(i1 + i2 + i3 + i4)
for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            all_combinations.append(i1 + i2 + i3)
selected_num = []
for i in all_combinations:
    if not ("7" in i):
        continue
    if not ("5" in i):
        continue
    if not ("3" in i):
        continue
    selected_num.append(int(i))
selected_num_array = np.array(selected_num)
print((np.sum(selected_num_array <= n)))

import numpy as np
from itertools import product

s = eval(input())
n = int(s)
digit = len(s)
selected_num = []
for order in range(3, 10, 1):
    for i in product("753", repeat=order):
        concat_str = "".join(i)
        if ("7" in concat_str) and ("5" in concat_str) and ("3" in concat_str):
            selected_num.append(int(concat_str))
selected_num_array = np.array(selected_num)
print((np.sum(selected_num_array <= n)))

+from itertools import product -all_combinations = [] -for i1 in ("3", "5", "7"): -    for i2 in ("3", "5", "7"): -        for i3 in ("3", "5", "7"): -            for i4 in ("3", "5", "7"): -                for i5 in ("3", "5", "7"): -                    for i6 in ("3", "5", "7"): -                        for i7 in ("3", "5", "7"): -                            for i8 in ("3", "5", "7"): -                                for i9 in ("3", "5", "7"): -                                    all_combinations.append( -                                        i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 -                                    ) -for i1 in ("3", "5", "7"): -    for i2 in ("3", "5", "7"): -        for i3 in ("3", "5", "7"): -            for i4 in ("3", "5", "7"): -                for i5 in ("3", "5", "7"): -                    for i6 in ("3", "5", "7"): -                        for i7 in ("3", "5", "7"): -                            for i8 in ("3", "5", "7"): -                                all_combinations.append( -                                    i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 -                                ) -for i1 in ("3", "5", "7"): -    for i2 in ("3", "5", "7"): -        for i3 in ("3", "5", "7"): -            for i4 in ("3", "5", "7"): -                for i5 in ("3", "5", "7"): -                    for i6 in ("3", "5", "7"): -                        for i7 in ("3", "5", "7"): -                            all_combinations.append(i1 + i2 + i3 + i4 + i5 + i6 + i7) -for i1 in ("3", "5", "7"): -    for i2 in ("3", "5", "7"): -        for i3 in ("3", "5", "7"): -            for i4 in ("3", "5", "7"): -                for i5 in ("3", "5", "7"): -                    for i6 in ("3", "5", "7"): -                        all_combinations.append(i1 + i2 + i3 + i4 + i5 + i6) -for i1 in ("3", "5", "7"): -    for i2 in ("3", "5", "7"): -        for i3 in ("3", "5", "7"): -            for i4 in ("3", "5", "7"): -                for i5 in ("3", "5", "7"): -                    all_combinations.append(i1 + i2 + i3 + i4 + i5) -for i1 in ("3", "5", "7"): -    for i2 in ("3", "5", "7"): -        for i3 in ("3", "5", "7"): -            for i4 in ("3", "5", "7"): -                all_combinations.append(i1 + i2 + i3 + i4) -for i1 in ("3", "5", "7"): -    for i2 in ("3", "5", "7"): -        for i3 in ("3", "5", "7"): -            all_combinations.append(i1 + i2 + i3) -for i in all_combinations: -    if not ("7" in i): -        continue -    if not ("5" in i): -        continue -    if not ("3" in i): -        continue -    selected_num.append(int(i)) +for order in range(3, 10, 1): +    for i in product("753", repeat=order): +        concat_str = "".join(i) +        if ("7" in concat_str) and ("5" in concat_str) and ("3" in concat_str): +            selected_num.append(int(concat_str))