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

public class HappyFull implements Runnable {

	private void printSmallest(char[] n, int i, int seven, int four) {

		try {
			for(int j = 0; j < i; ++j) {
				out.write(n[j]);
			}
			while(four-- > 0) {
				out.write('4');
			}
			while(seven-- > 0) {
				out.write('7');
			}
			out.write('\n');
			out.flush();
		}
		catch (IOException e) {}
	}

	public void run() {

		int l = 0;
		char[] n = new char[100003];

		try {
			int current = in.read();

			while(current != '\r' && current != '\n') {
				n[l++] = (char)current;
				current = in.read();
			}
		}
		catch (IOException ex) {
			return;
		}

		if(l % 2 == 1) {
			printSmallest(n, 0, (l + 1) / 2, (l + 1) / 2);
			return;
		}

		int seven = l / 2, four = l / 2;

		int fi = -1, fFour = 0, fSeven = 0;

		int i = 0;

		while(i < l) {

			if(n[i] > '7' || (seven == 0 && n[i] > '4')) {
				if(fi < 0) {
					i = 0;
					seven = l / 2 + 1;
					four = l / 2 + 1;
					break;
				}
				else {
					n[fi] = '7';
					seven = fSeven - 1;
					four = fFour;
					i = fi + 1;
					break;
				}
			}

			char t = n[i];

			if(t <= '4' && four > 0) {

				if(seven > 0) {
					fi = i;
					fFour = four;
					fSeven = seven;
				}

				n[i++] = '4';
				four--;

				if(t < '4') break;
				else continue;
			}

			n[i++] = '7';
			seven--;

			if(t < '7') break;
		}

		printSmallest(n, i, seven, four);
	}

	private InputStream in;
	private OutputStream out;

	public HappyFull(InputStream in, PrintStream out) {
		this.in =  new BufferedInputStream(in);
		this.out = new BufferedOutputStream(out);
	}

	public static void main(String[] args) {
		new HappyFull(System.in, System.out).run();
	}
}