def dfs(s,flag):

    if s>N:

        return 0

    ret =1 if flag==7 else 0

    ret+=dfs(s*10+3,flag|1)    

    ret+=dfs(s*10+5,flag|2)

    ret+=dfs(s*10+7,flag|4)

    return ret



N=int(eval(input()))

print((dfs(0,0)))

def dfs(s,flag):

    if s>upbd:

        return 0

    ret =1 if flag==7 else 0

    ret+=dfs(s*10+3,flag|1)    

    ret+=dfs(s*10+5,flag|2)

    ret+=dfs(s*10+7,flag|4)

    return ret



upbd=int(eval(input()))

print((dfs(0,0)))
def dfs(s, flag):
    if s > N:
        return 0
    ret = 1 if flag == 7 else 0
    ret += dfs(s * 10 + 3, flag | 1)
    ret += dfs(s * 10 + 5, flag | 2)
    ret += dfs(s * 10 + 7, flag | 4)
    return ret


N = int(eval(input()))
print((dfs(0, 0)))

def dfs(s, flag):
    if s > upbd:
        return 0
    ret = 1 if flag == 7 else 0
    ret += dfs(s * 10 + 3, flag | 1)
    ret += dfs(s * 10 + 5, flag | 2)
    ret += dfs(s * 10 + 7, flag | 4)
    return ret


upbd = int(eval(input()))
print((dfs(0, 0)))

-    if s > N: +    if s > upbd: -N = int(eval(input())) +upbd = int(eval(input()))