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:
import sys
from sys import stdin
import math
#Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))
def iinput():
    return int(input())
def minput():
    return map(int,input().split())
def linput():
    return list(map(int,input().split()))

def fiinput():
    return int(stdin.readline())
def fminput():
    return map(int,stdin.readline().strip().split())
def flinput():
    return list(map(int,stdin.readline().strip().split()))

flist=[]





def solve(x,i):
    if(i<len(x)):
        ll=x.copy()
        ll[i]="4"
        solve(ll,i+1)
        ll[i]="7"
        solve(ll,i+1)
    else:
        c1=x.count("4")
        c2=x.count("7")
        if(c1==c2 and c1+c2==len(x)):
            s="".join(x)
            flist.append(s)
            

x=(input())
x1=x
if(len(x)%2!=0):
    x=x+"0"
if(int(x1)>=int("7"*(len(x)//2)+"4"*(len(x)//2))):
    x=x+"00"
x=list(x)

countof4=0
count0f7=0
other=0
for i in range(len(x)):
    if(x[i]=="4"):
        countof4+=1
    elif(x[i]=="7"):
        count0f7+=1
    else:
        other+=1

solve(x,0)

flist.sort()
# s1="".join(x)
for i in range(len(flist)):
    if(int(flist[i])>=int(x1)):
        print(flist[i])
        break

# for i in range(len(x)):
#     if(x[i]!="4" and x[i]!="7"):
#         if(x[i]<"4"):
#             x[i]="4"
#             countof4+=1
#         else:
#             x[i]="7"
#             count0f7+=1
#         other-=1
#         break

ll=[]
for i in range(len(x)):
    list2=x.copy()
    
    ll.append(x)