n = int(eval(input()))



def nngg(m):

    if int(m) > n:

        return 0

    ret = 1 if all(m.count(s)>0 for s in '375') else 0

    for s in '357':

        ret += nngg(m+s)

    return ret



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



tmpl = [['']]

l = []

for i in range(1,10):

    #iは桁数

    tmp = []

    for x in tmpl[-1]:

        for s in '357':

            tmp.append(x+s)

    tmpl.append(tmp)

    l = l + tmp



def check(s):

    if all(s.count(x) for x in '357'):

        return True

    else:

        return False



ans = 0

for x in l:

    if int(x) <= n:

        if check(x):

            ans += 1

    else:

        break



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


def nngg(m):
    if int(m) > n:
        return 0
    ret = 1 if all(m.count(s) > 0 for s in "375") else 0
    for s in "357":
        ret += nngg(m + s)
    return ret


print((nngg("0")))

n = int(eval(input()))
tmpl = [[""]]
l = []
for i in range(1, 10):
    # iは桁数
    tmp = []
    for x in tmpl[-1]:
        for s in "357":
            tmp.append(x + s)
    tmpl.append(tmp)
    l = l + tmp


def check(s):
    if all(s.count(x) for x in "357"):
        return True
    else:
        return False


ans = 0
for x in l:
    if int(x) <= n:
        if check(x):
            ans += 1
    else:
        break
print(ans)

+tmpl = [[""]] +l = [] +for i in range(1, 10): +    # iは桁数 +    tmp = [] +    for x in tmpl[-1]: +        for s in "357": +            tmp.append(x + s) +    tmpl.append(tmp) +    l = l + tmp -def nngg(m): -    if int(m) > n: -        return 0 -    ret = 1 if all(m.count(s) > 0 for s in "375") else 0 -    for s in "357": -        ret += nngg(m + s) -    return ret +def check(s): +    if all(s.count(x) for x in "357"): +        return True +    else: +        return False -print((nngg("0"))) +ans = 0 +for x in l: +    if int(x) <= n: +        if check(x): +            ans += 1 +    else: +        break +print(ans)