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.Arrays;
import java.util.Scanner;

public class Q3 {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        long l =4444477777l;
        long arr[] = {47,74,4477,4747,7447,4774,7474,7744,444777,447477,474477,744477,447747,474747,744747,477447,747447,774447,447774,474774,744774,477474,747474,774474,477744,747744,774744,777444,44447777,44474777,44744777,47444777,74444777,44477477,44747477,47447477,74447477,44774477,47474477,74474477,47744477,74744477,77444477,44477747,44747747,47447747,74447747,44774747,47474747,74474747,47744747,74744747,77444747,44777447,47477447,74477447,47747447,74747447,77447447,47774447,74774447,77474447,77744447,44477774,44747774,47447774,74447774,44774774,47474774,74474774,47744774,74744774,77444774,44777474,47477474,74477474,47747474,74747474,77447474,47774474,74774474,77474474,77744474,44777744,47477744,74477744,47747744,74747744,77447744,47774744,74774744,77474744,77744744,47777444,74777444,77477444,77747444,77774444,l};

        Arrays.sort(arr);

        for(int  i =0;i<N;i++){
            if(arr[i]>=N){
                System.out.println(arr[i]);
                return;
            }
        }
    }

}