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.io.*;
import java.util.*;

/**
 *
 * @author itymchenko
 */
public class taskB {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String num = null;
    boolean found = false;
    int needLen = 0;
    char[] x = null;
    int digit4 = 0, digit7 = 0;
    boolean bigger = false;

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

    void go(int pos) {
        if (found) {
            return;
        }
        if (!bigger) {
            if (pos > 0 && x[pos - 1] > num.charAt(pos - 1)) {
                bigger = true;
            }
        }
        if (pos == needLen) {
            found = digit4 == 0 && digit7 == 0;
            return;
        }

        // can we use 4?
        if (digit4 > 0 && ((!bigger && num.charAt(pos) <= '4') || bigger)) {
            digit4--;
            x[pos] = '4';
            go(pos+1);
            digit4++;
        }
        if (found) {
            return;
        }
        // can we use 7?
        if (digit7 > 0 && (!bigger && num.charAt(pos) <= '7') || bigger) {
            digit7--;
            x[pos] = '7';
            go(pos+1);
            digit7++;
        }
    }

    void main() throws IOException {
        num = br.readLine();
        num = (num.length() % 2 == 0 ? "" : "0") + num;
        needLen = num.length();
        x = new char[needLen];
        digit4 = needLen / 2;
        digit7 = needLen / 2;
        bigger = false;
        go(0);

        if (!found) {
            num = "00" + num;
            needLen += 2;
            x = new char[needLen];
            digit4 = needLen / 2;
            digit7 = needLen / 2;
            bigger = false;
            go(0);
        }

        System.out.println(x);
    }
}