N = int(eval(input()))



def dfs(s):

    if int(s) > N:

        return 0

    ans = 1 if all (s.count(c) > 0 for c in "753") else 0

    

    for c in "753":

        ans += dfs(s+c)

    return ans

print((dfs('0')))
# ABC114



N = int(eval(input()))

def dfs(num):

    if num > N:

        return 0

    flag = True

    for s in "357":

        if str(num).count(s) >= 1:

            pass

        else:

            flag = False

    ret = 1 if flag else 0



    for c in [3, 5, 7]:

        ret += dfs(num * 10 + c)

    return ret

ans = dfs(0)

print(ans)
N = int(eval(input()))


def dfs(s):
    if int(s) > N:
        return 0
    ans = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ans += dfs(s + c)
    return ans


print((dfs("0")))

# ABC114
N = int(eval(input()))


def dfs(num):
    if num > N:
        return 0
    flag = True
    for s in "357":
        if str(num).count(s) >= 1:
            pass
        else:
            flag = False
    ret = 1 if flag else 0
    for c in [3, 5, 7]:
        ret += dfs(num * 10 + c)
    return ret


ans = dfs(0)
print(ans)

+# ABC114 -def dfs(s): -    if int(s) > N: +def dfs(num): +    if num > N: -    ans = 1 if all(s.count(c) > 0 for c in "753") else 0 -    for c in "753": -        ans += dfs(s + c) -    return ans +    flag = True +    for s in "357": +        if str(num).count(s) >= 1: +            pass +        else: +            flag = False +    ret = 1 if flag else 0 +    for c in [3, 5, 7]: +        ret += dfs(num * 10 + c) +    return ret -print((dfs("0"))) +ans = dfs(0) +print(ans)