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:
def gen_numbers(N):
    arr = ['']
    i = 0
    while i<N:
        i += 1
        S = []
        for n in arr:
            S.append(n+'4')
            S.append(n+'7')
        arr = S
    R = []
    for i in arr:
        if i.count('4')==i.count('7'):
            R.append(int(i))
    return R

def highest(N):
    return '7'*(N/2)+'4'*(N/2)

def lowest(N):
    return '4'*(N/2)+'7'*(N/2)
    

def upper_bound(arr, x):
    ##exists

    if x <= arr[0]:
        return arr[0]

    if x>arr[-2] and x<=arr[-1]:
        return arr[-1]

    high = len(arr)-1
    low = 0

    while True:

        mid = (high+low)/2
        #print high, mid, low
        
        if arr[mid]>=x and arr[mid-1]<x:
            return arr[mid]
        elif arr[mid]>x and arr[mid-1]>x:
            high = mid
        elif arr[mid]<x and arr[mid-1]<x:
            low = mid


#arr = [1, 21, 37, 42, 72]
        
n = input()

#print upper_bound(arr, n)


s = str(n)
N = len(s)
if N%2==0:
    if n>int(highest(N)):
        N += 2
        print lowest(N)
    else:
        arr = gen_numbers(N)
        print upper_bound(arr, n)
else:
    print lowest(N+1)