#2877번 4와 7
import sys
import math
input = sys.stdin.readline
N = int(input())
digit = 1
word = []
while True:
if 2**(digit) - 1 <= N and N <= 2**(digit+1) - 2:
break
else:
digit += 1
while digit != 0:
if 2**(digit) - 1 <= N and N <= 2**(digit) -2 + (2**(digit - 1)):
word.append("4")
N -= 2**(digit - 1)
digit -= 1
else:
word.append("7")
N -= 2**digit
digit -= 1
result = "".join(str(s) for s in word)
print(result)