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

public class Main implements Runnable {

	final String filename = "";

	public void solve() throws Exception {
		String s = readword();
		int n = s.length();
		boolean flag = false;
		if (n % 2 == 0) {
			int best = -1, last = -1;
			int fours = 0, seven = 0;
			for (int i = 0; i < n; i++) {
				int x = s.charAt(i) - '0';
				// trying 4, trying 7
				if (x < 7 && Math.abs(fours - (seven + 1)) <= n - i - 1) {
					best = i;
					last = 7;
				}
				if (x < 4 && Math.abs(fours + 1 - seven) <= n - i - 1) {
					best = i;
					last = 4;
				}
				if (x != 4 && x != 7)
					break;
				if (x == 4)
					fours++;
				else
					seven++;
			}
			if (seven == fours && seven + fours == n) {
				best = n;
				last = -1;
			}
			if (best >= 0) {
				fours = 0;
				seven = 0;
				flag = true;
				for (int i = 0; i < best; i++) {
					int x = s.charAt(i) - '0';
					out.write((char) (x + '0'));
					if (x == 4)
						fours++;
					else
						seven++;
				}
				if (best < n) {
					out.write((char) (last + '0'));
					if (last == 4)
						fours++;
					else
						seven++;
				}
				for (int i = best + 1; i < n; i++) {
					if (fours * 2 < n) {
						out.write('4');
						fours++;
					} else {
						out.write('7');
						seven++;
					}
				}
				out.write("\n");
			}
		}
		if (!flag) {
			n++;
			if (n % 2 != 0)
				n++;
			for (int i = 0; i < n / 2; i++)
				out.write('4');
			for (int i = 0; i < n / 2; i++)
				out.write('7');
			out.write('\n');
		}
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedWriter(new OutputStreamWriter(System.out));
			// in = new BufferedReader(new FileReader(filename+".in"));
			// out = new BufferedWriter(new FileWriter(filename+".out"));
			solve();
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int iread() throws Exception {
		return Integer.parseInt(readword());
	}

	public double dread() throws Exception {
		return Double.parseDouble(readword());
	}

	public long lread() throws Exception {
		return Long.parseLong(readword());
	}

	BufferedReader in;

	BufferedWriter out;

	public String readword() throws IOException {
		StringBuilder b = new StringBuilder();
		int c;
		c = in.read();
		while (c >= 0 && c <= ' ')
			c = in.read();
		if (c < 0)
			return "";
		while (c > ' ') {
			b.append((char) c);
			c = in.read();
		}
		return b.toString();
	}

	public static void main(String[] args) {
		try {
			Locale.setDefault(Locale.US);
		} catch (Exception e) {

		}
		// new Thread(new Main()).start();
		new Thread(null, new Main(), "1", 1 << 25).start();
	}
}