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.*;
import java.io.*;
import java.math.BigInteger;
import static java.lang.Math.*;

public class Sol implements Runnable {

	void printFirst(int n) {
		if (n % 2 == 1) n++;
		for (int i = 0; i < n / 2; i++) {
			out.print('4');
		}
		for (int i = 0; i < n / 2; i++) {
			out.print('7');
		}
	}

	void solve() throws Exception {
		char [] c = nextToken().toCharArray();
		int n = c.length;
		if (n % 2 == 1) {
			printFirst(n);
			return;
		}

		int [] f = new int[n + 1];
		int [] s = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			f[i] = f[i - 1];
			s[i] = s[i - 1];
			if (c[i - 1] == '4') f[i]++;
			if (c[i - 1] == '7') s[i]++;
		}

		for (int i = n; i >= 0; i--) {
			if (s[i] + f[i] != i) continue;

			if (i == n) {
				if (s[i] == n / 2 && f[i] == n / 2) {
					out.println(new String(c));
					return;
				}
				continue;	
			}

			if (c[i] < '4') {
				int addF = (s[i] + n - f[i] - i) / 2 - 1;
				if (0 <= addF && addF <= n - i - 1) {
					c[i] = '4';
					for (int j = 0; j < n - i - 1; j++) {
						c[j + i + 1] = j < addF ? '4' : '7';					
					}
					out.println(new String(c));
					return;			
				}
			}

			if (c[i] < '7') {
				int addF = (s[i] + n - f[i] - i) / 2;
				if (0 <= addF && addF <= n - i - 1) {
					c[i] = '7';
					for (int j = 0; j < n - i - 1; j++) {
						c[j + i + 1] = j < addF ? '4' : '7';
					}
					out.println(new String(c));
					return;
				}
			}
		}

		printFirst(n + 1);
	}

	public static void main(String[] args) {
		new Thread(new Sol()).start();
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	
	StringTokenizer tokenizer = new StringTokenizer("");
	BufferedReader in;
	PrintWriter out;
	long time;

	void sTime() {
		time = System.currentTimeMillis();
	}

	long gTime() {
		return System.currentTimeMillis() - time;
	}

	void gMemory() {
		debug("Memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000 + " kb");
	}

	public void debug(Object o) {
		System.err.println(o);
	}
	
	boolean seekForToken() {
		while (!tokenizer.hasMoreTokens()) {
			String s = null;
			try {
				s = in.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (s == null)
				return false;
			tokenizer = new StringTokenizer(s);
		}
		return true;
	}

	String nextToken() {
		return seekForToken() ? tokenizer.nextToken() : null;
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	BigInteger nextBig() {
		return new BigInteger(nextToken());
	}
}