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

Solution:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.math.BigInteger;
import java.util.*;

/**
 *
 * @author Centrino Laptop
 */
public class test1 {
 static int  min0;
 static  BigInteger   x1;
  static BigInteger  lucky=new BigInteger("99999999999999");
 public static void re(String s,int i,int i1) {
   if(i1==0)
 {
     System.out.println(s);
     return;
 }
    
if(i!=0)
 re(s+'(',i-1,i1);
 if(i!=i1)
  re(s+')',i,i1-1);

 }
  public static void re3(String s,int i,int i1) {
   if(i1==i&&s!="")
 {if(lucky.compareTo(new BigInteger(s)) == 1&&  (x1.compareTo(new BigInteger(s))==-1||x1.compareTo(new BigInteger(s))==0))
 {lucky =new BigInteger(s);
   return;
 
 }
    
   
 }
    
if(i!=0)
 re3(s+'4',i-1,i1);
 if(0!=i1)
  re3(s+'7',i,i1-1);

 }
 public static void re1(int []s,int sum,int count,int i) {
       if(i==s.length) 
    {
   if(count<min0 &&sum==0)
 min0=count;
    
    return;
    }
re1(s,sum+s[i],count,i+1);
re1(s,sum-s[i],count+1,i+1);


 }
    public static void main(String[] args) {
    Scanner in =new Scanner(System.in);
//   \* int n=in.nextInt();
//    int []a=new int [n];
//    char ch;
//  a[0]=in.nextInt();
//
//        for (int i = 1; i < n; i++) {
//             ch=in.next().charAt(0);
//           int x=in.nextInt();
//             if(ch=='-')
//                 x=x*-1;
//             a[i]=x;
//         
//        }
//        
//            min0=n+6;
//        re1(a,a[0],0,1);
//   
//       if(min0==n+6)
//            System.out.println("-1");
//      else
//            System.out.println(min0); 
String s=in.next();
x1=new BigInteger(s);

re3("",s.length()/2+s.length()%2+1,s.length()/2+s.length()%2+1);
        System.out.println(lucky);
      
    }

}