n = int(eval(input()))

def dfs(x):

    if int(x) > n:

        return 0

    

    if all(x.count(i) > 0 for i in "753"):

        ret = 1

    else:

        ret = 0

    

    for i in "753":

        ret += dfs(x+i)

        

    return ret

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



count = 0

def dfs(x):

    global count

    if int(x) > n:

        return 0

    

    for i in ('753'):

        dfs(x+i)

    

    check =  True

    for j in ('753'):

        if x.find(j) == -1:

            check = False

    if check:

        count += 1

        

    return count

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


def dfs(x):
    if int(x) > n:
        return 0
    if all(x.count(i) > 0 for i in "753"):
        ret = 1
    else:
        ret = 0
    for i in "753":
        ret += dfs(x + i)
    return ret


print((dfs("0")))

n = int(eval(input()))
count = 0


def dfs(x):
    global count
    if int(x) > n:
        return 0
    for i in "753":
        dfs(x + i)
    check = True
    for j in "753":
        if x.find(j) == -1:
            check = False
    if check:
        count += 1
    return count


print((dfs("0")))

+count = 0 +    global count -    if all(x.count(i) > 0 for i in "753"): -        ret = 1 -    else: -        ret = 0 -        ret += dfs(x + i) -    return ret +        dfs(x + i) +    check = True +    for j in "753": +        if x.find(j) == -1: +            check = False +    if check: +        count += 1 +    return count