from itertools import permutations

N = int(input())

A = set()
for digit in range(3, 10):
    for seven in range(1, digit - 1):
        for five in range(1, digit - seven):
            three = digit - seven - five
            for perm in permutations(["7"] * seven + ["5"] * five + ["3"] * three):
                A.add("".join(perm))
A = list(map(int, A))
A.sort()

if N in A:
    print(A.index(N) + 1)
else:
    A.append(N)
    A.sort()
    print(A.index(N))
