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.Scanner;

/**
 * Created by hapsi on 25.09.2016.
 */
public class Source {
    public static boolean next_variant(StringBuffer text) {
        boolean find = false;
        for (int i = text.length() - 2; i >= 0; i--) {
            if (text.charAt(i) == '4' && text.charAt(i + 1) == '7') {
                text.setCharAt(i, '7');
                text.setCharAt(i + 1, '4');

                for (int j = i + 2; j < (text.length() + i + 2) / 2; j++) {
                    char ct = text.charAt(j);
                    text.setCharAt(j, text.charAt(text.length() - (j - i - 1)));
                    text.setCharAt(text.length() - (j - i - 1), ct);
                }
                find = true;
                break;
            }
        }
        return find;
    }

    public static void main(String args[]) {
        Scanner scanner = null;
        try {
            scanner = new Scanner(System.in);
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        StringBuffer n = new StringBuffer(scanner.next());
        String original = n.toString();
        if (n.length() % 2 != 0) {
            for (int i = 0; i < (n.length() + 1) / 2; i++) {
                System.out.print('4');
            }
            for (int i = 0; i < (n.length() + 1) / 2; i++) {
                System.out.print('7');
            }
        } else {
            for (int i = 0; i < (n.length() + 1) / 2; i++) {
                n.setCharAt(i,'4');
            }
            for (int i = (n.length() + 1) / 2; i < n.length(); i++) {
                n.setCharAt(i, '7');
            }

            boolean not_find=true;

            if (n.toString().compareTo(original) >= 0) {
                System.out.println(n);
                not_find = false;
            }
            else {
                while (next_variant(n)) {
                    if (n.toString().compareTo(original) >= 0) {
                        System.out.println(n);
                        not_find=false;
                        break;
                    }
                }
            }

            if(not_find){
                n.setLength(n.length()+2);
                for (int i = 0; i < (n.length() + 1) / 2; i++) {
                    n.setCharAt(i,'4');
                }
                for (int i = (n.length() + 1) / 2; i < n.length(); i++) {
                    n.setCharAt(i, '7');
                }

                if (n.toString().compareTo(original) >= 0 || n.length()>original.length()) {
                    System.out.println(n);
                }
                else {
                    while (next_variant(n)) {
                        if (n.toString().compareTo(original) >= 0) {
                            System.out.println(n);
                            break;
                        }
                    }
                }
            }
        }
    }
}