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

import java.util.*;
import java.io.*;

public class D
{
    int []map = new int [8] ;
    int [] map2 = new int [2] ;
    char [] str ;
    int [] num ;

    boolean backTrack(int f , int s , int idx , boolean less)
    {
        if(f < 0 || s < 0) return false ;
        if(less)
        {
            for(int i = 0 ; i < f; i ++)
                num[i + idx] = 4 ;
            for(int i = 0 ; i < s; i ++)
                num[i + idx + f] = 7 ;
            return true ;
        }
        if(idx == str.length)return true ;

        if(str[idx] <= '4' && backTrack(f - 1 , s , idx + 1 , less | (str[idx] < '4')))
        {
            num[idx] = 4 ;
            return true ;
        }
        if(str[idx] <= '7' && backTrack(f  , s - 1 , idx + 1 , less | (str[idx] < '7')))
        {
            num[idx] = 7 ;
            return true ;
        }
        return false ;
    }
    void main() throws Exception
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        char [] s = str = sc.next().toCharArray() ;
        map[4] = 0 ; map[7] = 1 ;
        map2[0] = 4 ; map2[1] = 7 ;
        int n = s.length ;
        if(n % 2 == 1)
        {
            n ++ ;
            for(int i = 0 ; i < n / 2 ; i ++)
                out.print(4);
            for(int i = n / 2 ; i < n ; i ++)
                out.print(7);
        }
        else
        {
            num = new int [n] ;
            for(int i = 0 ; i < n ;i++)
                num[i] = s[i] - '0' ;

            if(!backTrack(n / 2 , n / 2 , 0 , false))
            {
                n += 2 ;
                for(int i = 0 ; i < n / 2 ; i ++)
                    out.print(4);
                for(int i = n / 2 ; i < n ; i ++)
                    out.print(7);
            }
            else for(int x : num) out.print(x);





        }

        out.flush();
        out.close();
    }
    class Scanner
    {
        BufferedReader br;
        StringTokenizer st;

        Scanner(InputStream in)
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws Exception
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        String nextLine() throws Exception
        {
            return br.readLine() ;
        }
        int nextInt() throws Exception { return Integer.parseInt(next()); }

        long nextLong() throws Exception { return Long.parseLong(next()); }

        double nextDouble() throws Exception { return Double.parseDouble(next());}
    }

    public static void main (String [] args) throws Exception
    {
        new D().main();
    }

}