Problem: Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. For example, numbers 47, 7744, 474477 are super lucky and 4, 744, 467 are not.

One day Petya came across a positive integer n. Help him to find the least super lucky number which is not less than n.

Input

The only line contains a positive integer n (1 ≤ n ≤ 10100000). This number doesn't have leading zeroes.

Output

Output the least super lucky number that is more than or equal to n.

Examples

Input

4500


Output

4747


Input

47


Output

47

Solution (in PYTHON3):

Solution:
from sys import stdin,stdout,setrecursionlimit
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush,nlargest
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm , accumulate
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
setrecursionlimit(10**9)
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353
# from sys import stdin
# input = stdin.readline
#def data(): return sys.stdin.readline().strip()
def data(): return input()
def num():return int(input())
def L(): return list(sp())
def LF(): return list(spf())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def spf(): return map(int, input.readline().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
def pmat(A):
    for ele in A:
        print(*ele,end="\n")
def pmat2(A):
    for ele in A:
        for j in ele:
            print(j,end='')
        print()
def iseven(n):
    return n%2==0

def seive(r):
    prime=[1 for i in range(r+1)]
    prime[0]=0
    prime[1]=0
    for i in range(r+1):
        if(prime[i]):
            for j in range(2*i,r+1,i):
                prime[j]=0
    return prime
#solution
#ACPC 
#remeber cut ribbon problem
# set data structures faster than binary search sometimes
#bipartite match dfs
#think in problems with recursive manner.
sa=int(input())
suplucky=[47, 74, 4477, 4747, 4774, 7447, 7474, 7744, 747447, 744747, 744774, 477744, 444777, 777444, 447477, 747474, 774744, 474774, 474477, 447747, 774474, 447774, 744477, 774447, 747744, 477447, 477474, 474747]
supluckyb=[44747747, 77774444, 74747744, 44477774, 47447774, 77744474, 77444477, 47744774, 74477474, 74744774, 44774477, 77444747, 74474747, 74447747, 74447774, 44747774, 74477447, 74474477, 47744747, 47474747, 77447474, 77444774, 77474744, 74447477, 77474447, 74747474, 74774744, 47744477, 74777444, 44447777, 47747474, 47774474, 47747447, 44774747, 47444777, 44474777, 77474474, 74477744, 47477744, 74474774, 74747447, 47447477, 47477447, 44477477, 77747444, 77744744, 44744777, 77477444, 74744477, 47474774, 74444777, 44747477, 44777744, 47774744, 44777447, 47477474, 47447747, 47777444, 74774447, 44477747, 77447447, 77744447, 74774474, 44774774, 74744747, 47774447, 47474477, 77447744, 44777474, 47747744]
superlucky=suplucky+supluckyb
ans=[]
for i in superlucky:
	if i>=sa:
		ans.append(i)
if not ans:
	print(4444477777)
else:print(min(ans))

		
endtime = time.time()
#print(f"Runtime of the program is {endtime - starttime}")