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.math.*;
import java.util.*;
import java.awt.geom.*;

import javax.management.RuntimeErrorException;

import static java.lang.Math.*;

public class Solution implements Runnable{

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	private String next() throws Exception {
		if (st == null || !st.hasMoreTokens()) {
			String line=in.readLine().trim();
			while(line.length() == 0)
				line=in.readLine().trim();
			st = new StringTokenizer(line);
		}
		return st.nextToken();
	}

	private int nextInt() throws Exception {
		return Integer.parseInt(next());
	}
	private long nextLong() throws Exception {
		return Long.parseLong(next());
	}
	private double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) {
		new Thread(null, new Solution(), "", (1<<25)).start();
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			out.close();
		}
	}
	
	String cur;
	
	String getBad(int len) {
		StringBuilder ret = new StringBuilder();
		for (int i=0;i<len/2;i++)
			ret.append('4');
		for (int i=0;i<len/2;i++)
			ret.append('7');
		return ret.toString();
	}
	
	public void solve() throws Exception {
		cur=next();
		char [] s = cur.toCharArray();
		int len=cur.length();
		if (len%2==0) {
			boolean isBig=false;
			boolean error=false;
			int n4=0,n7=0;
			for (int i=0;i<len;i++) {
				if (isBig) {
					if (n4<len/2) {
						n4++; s[i]='4';
					} else {
						n7++; s[i]='7';
					}
				} else {
					if (s[i]<'4') {
						if (n4<len/2) {
							n4++; s[i]='4';
						} else {
							n7++; s[i]='7';
						}
						isBig=true;
					} else if (s[i]=='4') {
						if (n4<len/2) {
							n4++; s[i]='4';
						} else {
							n7++; s[i]='7';
							isBig=true;
						}
					} else if (s[i]>'4' && s[i]<='7') {
						if (s[i]<'7') isBig=true;
						n7++; s[i]='7';
					} else error=true;
				}
				if (n7>len/2) error=true;
				if (error) {
					if (n4==0) {
						out.println(getBad(len+2));
						return;
					} else {
						for (int k=i;k>=0;k--) {
							if (s[k]=='4') {
								n4--;
								if (n7<len/2) {
									n7++; s[k]='7';
									isBig=true;
									error=false;
									i=k;
									break;
								}
							}
							if (s[k]=='7') n7--;
						}
						if (n4==0 && n7==0) {
							out.println(getBad(len+2));
							return;
						}
					}
				}
			}
			out.println(s);
		} else {
			out.println(getBad(len+1));
		}
	}
}