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.awt.*;
import java.io.*;
import java.lang.annotation.ElementType;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;


public class  Main{
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastInput input = new FastInput(inputStream);
        FastOutput out = new FastOutput(outputStream);
        String str =input.readString();
        StringBuilder sb=new StringBuilder();
        if(str.length()%2!=0){
            for(int i=0;i<str.length()/2+1;i++){
                sb.append("4");
            }
            for(int i=0;i<str.length()/2+1;i++){
                sb.append("7");
            }

        }
        else {
            int qi=str.length()/2,si=str.length()/2,poi=-1,pox=-1;
            boolean more=false;
            boolean hav=false;
            for(int i=0;i<str.length();i++){
                char a=str.charAt(i);
                if(a=='7'){
                    if(qi==0){
                        if(poi>=0){
                            for(int j=i-1;j>=poi;j--){
                                if(sb.charAt(j)=='7'){
                                    qi++;
                                }
                                else{
                                    si++;
                                }
                                sb.deleteCharAt(j);
                            }
                            sb.append("7");
                            qi--;
                            break;
                        }
                        else{
                            more=true;
                        }
                    }
                    qi--;
                    sb.append("7");
                }
                else if(a=='4'){
                    if(si==0){
                        break;
                    }
                    sb.append("4");
                    si--;
                    if(qi>0) poi=i;
                }
                else if(a>'7'){
                    if(poi>=0){
                        for(int j=i-1;j>=poi;j--){
                            if(sb.charAt(j)=='7')
                                qi++;
                            else{
                                si++;
                            }
                            sb.deleteCharAt(j);
                        }
                        sb.append("7");
                        qi--;
                        break;
                    }
                    else{
                        more=true;
                    }
                }
                else if(a>'4'){
                    sb.append("7");
                    qi--;
                    break;
                }
                else {
                    sb.append("4");
                    si--;
                    break;
                }
            }
            if(more){
                sb=new StringBuilder();
                for(int i=0;i<str.length()/2+1;i++){
                    sb.append("4");
                }
                for(int i=0;i<str.length()/2+1;i++){
                    sb.append("7");
                }
            }
            else{
                for(int i=si;i>0;i--){
                    sb.append("4");
                }
                for(int i=qi;i>0;i--){
                    sb.append("7");
                }
            }
        }
        System.out.println(sb);
        out.close();
    }
    static class FastInput {
        private final InputStream is;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;
        public FastInput(InputStream is) {
            this.is = is;
        }
        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }
        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }
        public String next() {
            return readString();
        }
        public int scanInt() {
            int sign = 1;
            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }
            int val = 0;
            while (next >= '0' && next <= '9') {
                val = val * 10 + next - '0';
                next = read();
            }
            return (sign*val);
        }

        public String readString(StringBuilder builder) {
            skipBlank();
            while (next > 32) {
                builder.append((char) next);
                next = read();
            }
            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

    }
    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(1 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(String c) {
            cache.append(c);
            return this;
        }
        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }
        public FastOutput println(int c) {
            return append(c).println();
        }
        public FastOutput println(String c) {
            cache.append(System.lineSeparator());
            return append(c).println();
        }
        public FastOutput print(String c) {
            return append(c).println();
        }
        public FastOutput println() {
//            flush();
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }
    }
}