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:
#!/usr/bin/env python
#
# Author:  Yotam Medini  yotam.medini@gmail.com -- Created: 2006/May/11
#
# Next Permutation
#

import sys


def next_permutation(a):
    n = len(a)
    # Find last increasing pair
    i = n - 2
    while i >= 0 and a[i] >= a[i+1]:
        i -= 1
    if i < 0:
        a = None  # a is decreasing, no more permutations
    else:
        # Find last greater than a[i].
        # There must be one! since a[i] < a[i+1].
        j = n - 1
        while a[i] >= a[j]:
            j -= 1
        # and swap
        t = a[i];  a[i] = a[j];  a[j] = t

        # Mirror the tail. Swap pairs from going from the sides to the center
        low = i + 1
        high = n - 1
        while low < high:
            t = a[low];  a[low] = a[high];  a[high] = t
            low += 1
            high -= 1
    return a

def list2int(a):
	sum = 0
	for x in a:
		sum = sum *10 + x
	return sum

arr = []
a = [4,7]
while a != None:
	arr.append(list2int(a))
	a = next_permutation(a)
a = [4,4,7,7]
while a != None:
	arr.append(list2int(a))
	a = next_permutation(a)
a = [4,4,4,7,7,7]
while a != None:
	arr.append(list2int(a))
	a = next_permutation(a)
a = [4,4,4,4,7,7,7,7]
while a != None:
	arr.append(list2int(a))
	a = next_permutation(a)
arr.append(4444477777)

q = raw_input()
for x in arr:
	if x >= int(q):
		print x
		break


"""
# Program begins
n = 3;  # Just a guess
if len(sys.argv) > 1:
    n = int(sys.argv[1])
a = range(n) # First (increasing) permutation
a = [4,4,4,4,7,7,7,7]
permi = 0
while a != None:
    sys.stdout.write("Permutation[%3d] = %s\n" % (permi, a))
    a = next_permutation(a)
    permi += 1
sys.stdout.write("Total %s Permutations\n" % permi)
sys.exit(0)
"""