N = int(eval(input()))

def dfs(s):

  if int(s) > N:

    return 0

  else:

    if all(s.count(c) > 0 for c in "753"):

      cnt = 1

    else:

      cnt = 0

    for c in "753":

      cnt += dfs(s+c)

    return cnt

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

ans = 0



def dfs(n):

  global ans

  if n > N:

    return

  else:

    if all(str(n).count(c) > 0 for c in "357"):

      ans += 1

    dfs(10*n + 3)

    dfs(10*n + 5)

    dfs(10*n + 7)



dfs(0)

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


def dfs(s):
    if int(s) > N:
        return 0
    else:
        if all(s.count(c) > 0 for c in "753"):
            cnt = 1
        else:
            cnt = 0
        for c in "753":
            cnt += dfs(s + c)
        return cnt


print((dfs("0")))

N = int(eval(input()))
ans = 0


def dfs(n):
    global ans
    if n > N:
        return
    else:
        if all(str(n).count(c) > 0 for c in "357"):
            ans += 1
        dfs(10 * n + 3)
        dfs(10 * n + 5)
        dfs(10 * n + 7)


dfs(0)
print(ans)

+ans = 0 -def dfs(s): -    if int(s) > N: -        return 0 +def dfs(n): +    global ans +    if n > N: +        return -        if all(s.count(c) > 0 for c in "753"): -            cnt = 1 -        else: -            cnt = 0 -        for c in "753": -            cnt += dfs(s + c) -        return cnt +        if all(str(n).count(c) > 0 for c in "357"): +            ans += 1 +        dfs(10 * n + 3) +        dfs(10 * n + 5) +        dfs(10 * n + 7) -print((dfs("0"))) +dfs(0) +print(ans)