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

public class B {

    char[] d;
    int m, c4, c7;

    void solve() throws IOException {
        in("__std"); out("__std");

        d = readLine().toCharArray();
        if (d.length % 2 == 0) {
            m = d.length / 2;
            for (int i = 0; i < d.length; ++i) {
                if (d[i] == '4') {
                    ++c4;
                    if (c4 > m) {
                        fill(i);
                        break;
                    }
                } else if (d[i] == '7') {
                    ++c7;
                    if (c7 > m) {
                        tail(i);
                        break;
                    }
                } else {
                    if (d[i] < '4') {
                        fill(i);
                    } else {
                        if (d[i] < '7' && c7 < m) {
                            d[i] = '7';
                            ++c7;
                            fill(i + 1);
                        } else {
                            tail(i - 1);
                        }
                    }
                    break;
                }
            }
            println(String.valueOf(d));
        } else {
            dump(d.length + 1);
        }

        exit();
    }

    void tail(int i) {
        while (i >= 0 && (d[i] == '7' || c7 >= m)) {
            if (d[i--] == '7') {
                --c7;
            } else {
                --c4;
            }
        }
        if (i < 0) {
            dump(d.length + 2);
            exit();
        } else {
            d[i] = '7';
            --c4;
            ++c7;
            fill(i + 1);
        }
    }

    void fill(int i) {
        while (c4 < m) {
            d[i++] = '4';
            ++c4;
        }
        while (c7 < m) {
            d[i++] = '7';
            ++c7;
        }
    }

    void dump(int l) {
        for (int i = 0; i < l; ++i) {
            print(i < l / 2 ? '4' : '7');
        }
        println();
        exit();
    }

    void in(String name) throws IOException {
        if (name.equals("__std")) {
            in = new BufferedReader(new InputStreamReader(System.in));
        } else {
            in = new BufferedReader(new FileReader(name));
        }
    }

    void out(String name) throws IOException {
        if (name.equals("__std")) {
            out = new PrintWriter(System.out);
        } else {
            out = new PrintWriter(name);
        }
    }

    void exit() {
        out.close();
        System.exit(0);
    }

    int readInt() throws IOException {
        return Integer.parseInt(readToken());
    }

    long readLong() throws IOException {
        return Long.parseLong(readToken());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readToken());
    }

    String readLine() throws IOException {
        st = null;
        return in.readLine();
    }

    String readToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    boolean eof() throws IOException {
        return !in.ready();
    }

    void print(String format, Object ... args) {
        out.println(new Formatter(Locale.US).format(format, args));
    }

    void println(String format, Object ... args) {
        out.println(new Formatter(Locale.US).format(format, args));
    }

    void print(Object value) {
        out.print(value);
    }

    void println(Object value) {
        out.println(value);
    }

    void println() {
        out.println();
    }

    StringTokenizer st;

    BufferedReader in;
    PrintWriter out;

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