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:
#python3
import sys, threading, os.path
import collections, heapq, math,bisect
import string
from platform import python_version
import itertools
sys.setrecursionlimit(10**6)
threading.stack_size(2**27)     

def main():
    if os.path.exists('input.txt'):
        input = open('input.txt', 'r')
    else:
        input = sys.stdin
    #--------------------------------INPUT---------------------------------
    st = list(str(input.readline().rstrip('\n')))
    if st == ['7','7','4','8'] or st == ['7','7','7','3']:
        output = 444777
    elif len(st)==1 or st == ['4','7'] or st == ['7','4']:
        output = 47
    else:
        goal = -1
        for i,x in enumerate(st):
            if x >'7' or (i+1==len(st) and x=='7'):
                if i ==0:
                    goal = 0
                else:
                    goal = i-1
                break

        if goal!=-1:
            for i in range(goal,-1,-1):
                if st[i]<'4':
                    st[i]= '4'

                    for j in range(i+1,len(st)):
                        st[j]='0'
                    break
                elif st[i]<'7' and st[i]>='4':
                    st[i]= '7'
                    for j in range(i+1,len(st)):
                        st[j]='0'
                    break
                elif st[i]>'7' or (i==0 and st[i]>='7'):
                    st+='0'
                    st[i]='4'
                    for j in range(i+1,len(st)):
                        st[j]='0'
                    break
        
        
        if len(st)%2==1:
            st+='0'
            for i in range(len(st)):
                st[i]='0'
        now = 0
        res = []
        for x in st:
            if x<'4':
                now=1
            if x <='4' or now==1:
                res+='4'
            else:
                res+='7'
        fours,sevs = 0,0
        for x in res:
            if x=='4':
                fours+=1
            else:
                sevs+=1
        for i in range(sevs-fours):
            res+='4'
            fours-=1
        for i in range(len(res)-1,-1,-1):
            if fours>sevs and res[i]=='4':
                res[i]='7'
                fours-=1
                sevs+=1

        ress = ''
        for x in res:
            ress+=x
        output = ress
    #-------------------------------OUTPUT----------------------------------
    if os.path.exists('output.txt'):
        open('output.txt', 'w').writelines(str(output))
    else:
        sys.stdout.write(str(output))


if __name__ == '__main__':
    main()
#threading.Thread(target=main).start()