N = int(eval(input()))



def dfs(x):

    if int('0'+x) > N:

        return 0



    retval = 1 if len(set(x)) == 3 else 0

    for c in '753':

        retval += dfs(x + c)

    return retval





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

like_753 = []





def dfs(x):

    if n < x:

        return 0

    else:

        like_753.append(x)

        dfs(10*x+3)

        dfs(10*x+5)

        dfs(10*x+7)





dfs(3)

dfs(5)

dfs(7)



ls_753 = [x for x in like_753 if len(set(str(x))) == 3]

print((len(ls_753)))

N = int(eval(input()))


def dfs(x):
    if int("0" + x) > N:
        return 0
    retval = 1 if len(set(x)) == 3 else 0
    for c in "753":
        retval += dfs(x + c)
    return retval


print((dfs("")))

n = int(eval(input()))
like_753 = []


def dfs(x):
    if n < x:
        return 0
    else:
        like_753.append(x)
        dfs(10 * x + 3)
        dfs(10 * x + 5)
        dfs(10 * x + 7)


dfs(3)
dfs(5)
dfs(7)
ls_753 = [x for x in like_753 if len(set(str(x))) == 3]
print((len(ls_753)))

-N = int(eval(input())) +n = int(eval(input())) +like_753 = [] -    if int("0" + x) > N: +    if n < x: -    retval = 1 if len(set(x)) == 3 else 0 -    for c in "753": -        retval += dfs(x + c) -    return retval +    else: +        like_753.append(x) +        dfs(10 * x + 3) +        dfs(10 * x + 5) +        dfs(10 * x + 7) -print((dfs(""))) +dfs(3) +dfs(5) +dfs(7) +ls_753 = [x for x in like_753 if len(set(str(x))) == 3] +print((len(ls_753)))