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 static java.util.Arrays.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import java.util.*;
import java.math.*;
import java.io.*;

public class B implements Runnable
{
    String file = "input";
    
    boolean TEST = false;
    
    void solve() throws IOException
    {
        cs = next().toCharArray();
        int n = cs.length;
        as = new char[n];
        if(can(0, n / 2, n / 2, false)) out.println(as);
        else
        {
            int m = n / 2 + 1;
            for(int i = 0; i < m; i++) out.print('4');
            for(int i = 0; i < m; i++) out.print('7');
            out.println();
        }
    }
    char[] cs, as;
    boolean can(int i,  int four, int seven, boolean larger)
    {
        if(i == cs.length) return true;
        if(larger)
        {
            if(four > 0)
            {
                as[i] = '4';
                return can(i + 1, four - 1, seven, larger);
            }
            else if(seven > 0)
            {
                as[i] = '7';
                return can(i + 1, four, seven - 1, larger);
            }
            return false;
        }
        
        as[i] = '4';
        if(four > 0 && cs[i] <= '4' && can(i + 1, four - 1, seven, cs[i] < '4')) return true;
        as[i] = '7';
        if(seven > 0 && cs[i] <= '7' && can(i + 1, four, seven - 1, cs[i] < '7')) return true;
        return false;
    }
    
    String next() throws IOException
    {
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(input.readLine());
        return st.nextToken();
    }
    
    int nextInt() throws IOException
    {
        return Integer.parseInt(next());
    }
    
    long nextLong() throws IOException
    {
        return Long.parseLong(next());
    }
    
    double nextDouble() throws IOException
    {
        return Double.parseDouble(next());
    }
    
    void print(Object... o)
    {
        System.out.println(deepToString(o));
    }
    
    void gcj(Object o)
    {
        String s = String.valueOf(o);
        out.println("Case #" + test + ": " + s);
        System.out.println("Case #" + test + ": " + s);
    }
    
    BufferedReader input;
    PrintWriter out;
    StringTokenizer st;
    int test;
    
    void init() throws IOException
    {
        if(TEST) input = new BufferedReader(new FileReader(file + ".in")); 
        else input = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new BufferedOutputStream(System.out));
    }
    
    public static void main(String[] args) throws IOException
    {
        new Thread(null, new B(), "", 1 << 23).start();
    }
    
    public void run()
    {
        try
        {
            init();
            if(TEST) 
            {
                int runs = nextInt();
                for(int i = 0; i < runs; i++) solve();
            }
            else solve();
            out.close();        
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.exit(1);
        }
    }
}