n = int(eval(input()))



def solve(s):

    if int(s) > n:

        return 0

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

        count = 1

    else:

        count = 0

    count += solve(s + '7')

    count += solve(s + '5')

    count += solve(s + '3')

    return count



print((solve('0')))
def dfs(s):

    if int(s) > n:

        return 0

    return ('7' in s and '5' in s and '3' in s) + dfs(s + '7') + dfs(s + '5') + dfs(s + '3')





n = int(eval(input()))

print((dfs('0')))
n = int(eval(input()))


def solve(s):
    if int(s) > n:
        return 0
    if "7" in s and "5" in s and "3" in s:
        count = 1
    else:
        count = 0
    count += solve(s + "7")
    count += solve(s + "5")
    count += solve(s + "3")
    return count


print((solve("0")))

def dfs(s):
    if int(s) > n:
        return 0
    return (
        ("7" in s and "5" in s and "3" in s)
        + dfs(s + "7")
        + dfs(s + "5")
        + dfs(s + "3")
    )


n = int(eval(input()))
print((dfs("0")))

-n = int(eval(input())) +def dfs(s): +    if int(s) > n: +        return 0 +    return ( +        ("7" in s and "5" in s and "3" in s) +        + dfs(s + "7") +        + dfs(s + "5") +        + dfs(s + "3") +    ) -def solve(s): -    if int(s) > n: -        return 0 -    if "7" in s and "5" in s and "3" in s: -        count = 1 -    else: -        count = 0 -    count += solve(s + "7") -    count += solve(s + "5") -    count += solve(s + "3") -    return count - - -print((solve("0"))) +n = int(eval(input())) +print((dfs("0")))