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 PYTHON):

Solution:
'''                      
   	
   			 ||Sri:||                 

                      __|
 ______________|_________________________
      |    |   ___|    |    |    ___|      |      |    |___
 /\  /\    |   |___    |    |   |___|      |      |    |___|
/  \/  \   |   ___|    |    |         |_/    |___|    |___

I am a beginner. Feel free to send tutorials/help to srinivasan1995@gmail.com.

Codeforces, SPOJ handle: desikachariar.
Hackerrank, Codechef handle: Prof_Calculus.

Advices/Help are welcome. You will definitely get a thanks in return. Comments to be avoided.

College: International Institute of Information Technology, Bangalore.

'''

import math
from itertools import permutations
 
class unique_element:
    def __init__(self,value,occurrences):
        self.value = value
        self.occurrences = occurrences

def perm_unique(elements):
    eset=set(elements)
    listunique = [unique_element(i,elements.count(i)) for i in eset]
    u=len(elements)
    return perm_unique_helper(listunique,[0]*u,u-1)

def perm_unique_helper(listunique,result_list,d):
    if d < 0:
        yield tuple(result_list)
    else:
        for i in listunique:
            if i.occurrences > 0:
                result_list[d]=i.value
                i.occurrences-=1
                for g in  perm_unique_helper(listunique,result_list,d-1):
                    yield g
                i.occurrences+=1
if __name__ == '__main__':
	x = raw_input()
	a = (int((float(len(x))/2.0)+0.5))
	ls1 = ([4]* a) + ([7] * a)
	ls2 = ls1+[4,7]
	st = list(perm_unique(list(ls1))) + list(perm_unique(list(ls2)))
	for i in range(len(st)):
		temp = ''
		for j in st[i]:
			temp+=str(j)
		st[i] = int(temp)
	st.sort()
	x = int(x)
	for i in range(len(st)):
		if st[i] >= x:
			print st[i]
			break