def shichigo(s):

    if '3' not in s:

        return False

    if '5' not in s:

        return False

    if '7' not in s:

        return False

    x = s.replace('3','').replace('5','').replace('7','')

    if x=='':

        return True

    return False



n = eval(input())



l = [[] for i in range(len(n))]

l[0] = ['3','5','7']

for i in range(1,len(l)):

    for j in range(len(l[i-1])):

        l[i].append('3'+l[i-1][j])

        l[i].append('5'+l[i-1][j])

        l[i].append('7'+l[i-1][j])



ans = 0

for i in range(len(l)):

    for j in range(len(l[i])):

        if int(n) >= int(l[i][j]):

            if shichigo(l[i][j]):

                ans += 1



print(ans)

def shichigo(s):

    if '3' not in s:

        return False

    if '5' not in s:

        return False

    if '7' not in s:

        return False

    return True



n = eval(input())



l = [[] for i in range(len(n))]

l[0] = ['3','5','7']

for i in range(1,len(l)):

    for j in range(len(l[i-1])):

        l[i].append('3'+l[i-1][j])

        l[i].append('5'+l[i-1][j])

        l[i].append('7'+l[i-1][j])



ans = 0

for i in range(len(l)):

    for j in range(len(l[i])):

        if int(n) >= int(l[i][j]):

            if shichigo(l[i][j]):

                ans += 1



print(ans)

def shichigo(s):
    if "3" not in s:
        return False
    if "5" not in s:
        return False
    if "7" not in s:
        return False
    x = s.replace("3", "").replace("5", "").replace("7", "")
    if x == "":
        return True
    return False


n = eval(input())
l = [[] for i in range(len(n))]
l[0] = ["3", "5", "7"]
for i in range(1, len(l)):
    for j in range(len(l[i - 1])):
        l[i].append("3" + l[i - 1][j])
        l[i].append("5" + l[i - 1][j])
        l[i].append("7" + l[i - 1][j])
ans = 0
for i in range(len(l)):
    for j in range(len(l[i])):
        if int(n) >= int(l[i][j]):
            if shichigo(l[i][j]):
                ans += 1
print(ans)

def shichigo(s):
    if "3" not in s:
        return False
    if "5" not in s:
        return False
    if "7" not in s:
        return False
    return True


n = eval(input())
l = [[] for i in range(len(n))]
l[0] = ["3", "5", "7"]
for i in range(1, len(l)):
    for j in range(len(l[i - 1])):
        l[i].append("3" + l[i - 1][j])
        l[i].append("5" + l[i - 1][j])
        l[i].append("7" + l[i - 1][j])
ans = 0
for i in range(len(l)):
    for j in range(len(l[i])):
        if int(n) >= int(l[i][j]):
            if shichigo(l[i][j]):
                ans += 1
print(ans)

-    x = s.replace("3", "").replace("5", "").replace("7", "") -    if x == "": -        return True -    return False +    return True