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:
import java.util.*;
import java.io.*;
import java.math.*;
public class Solution{
    
    static void affiche(int n,PrintWriter out){
        for(int i=0;i<n/2;i++){
            out.print("4");
        }
        for(int i=0;i<n/2;i++){
            out.print("7");
        }
    }
    
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //StringTokenizer st = new StringTokenizer(br.readLine());
        
        PrintWriter out = new PrintWriter(System.out);
        
        //int n = Integer.parseInt(st.nextToken());
        String s = br.readLine();
        int n = s.length();
        int last = -1;
        if(n%2==1){
            n++;
            affiche(n,out);
        }else{
            int[] a = new int[n];
            for(int i=0;i<n;i++){
                a[i] = (int)(s.charAt(i)-'0');
            }
            boolean ok = true;;
            for(int i=0;i<n;i++){
                if(a[i]!=4 && a[i]!=7){
                    ok = false;
                    break;
                }
            }
            int four = 0;
            int seven = 0;
            for(int i=0;i<n;i++){
                if(a[i]==4) four++;
                else seven++;
            }
            if(four!=seven) ok = false;
            
            if(ok){
                out.print(s);
            }else{
            
        
                
                last = -1;
                four = 0;
                seven = 0;
                for(int i=0;i<n;i++){
                    if(a[i]>7) break;
                    if(a[i]!=4 && a[i]!=7){
                        if(a[i]<4) four++;
                        else seven++;
                        if(four+n-i-1>=seven) last = i;
                        break;
                    }
                    if(a[i]==4){
                        if(four+n-i-1>=seven+1) last = i;
                        four++;
                    }else seven++;
                    
                    if(four+n-i-1<seven) break;
                    
                }
                
                if(last==-1) {
                    affiche(n+2,out);
                }else{
                    
                    
                    four = 0;
                    seven = 0;
                    for(int i=0;i<last;i++){
                        out.print(a[i]);
                        if(a[i]==4) four++;
                        else seven++;
                    }
                    if(a[last]<4){
                        out.print("4");
                        four++;
                    } 
                    else{
                        out.print("7");
                        seven++;
                    } 
                    
                    for(int i=0;i<n/2 - four;i++){
                        out.print("4");
                    }
                    for(int i=0;i<n/2 - seven;i++){
                        out.print("7");
                    }
                    
                }
            }
        }
        out.println("");
        
        out.flush();
    }
    
}