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.IOException;
import java.util.Locale;
import java.util.Scanner;

public class B {

	long[] nn = {
			4444477777l, 4444747777l, 4444774777l, 4444777477l, 44447777l, 4444777747l, 4444777774l, 4447447777l, 4447474777l, 4447477477l, 44474777l, 4447477747l, 4447477774l, 4447744777l, 4447747477l, 44477477l, 4447747747l, 4447747774l, 444777l, 4447774477l, 44477747l, 4447774747l, 4447774774l, 44477774l, 4447777447l, 4447777474l, 4447777744l, 4474447777l, 4474474777l, 4474477477l, 44744777l, 4474477747l, 4474477774l, 4474744777l, 4474747477l, 44747477l, 4474747747l, 4474747774l, 447477l, 4474774477l, 44747747l, 4474774747l, 4474774774l, 44747774l, 4474777447l, 4474777474l, 4474777744l, 4477l, 4477444777l, 4477447477l, 44774477l, 4477447747l, 4477447774l, 447747l, 4477474477l, 44774747l, 4477474747l, 4477474774l, 44774774l, 4477477447l, 4477477474l, 4477477744l, 447774l, 4477744477l, 44777447l, 4477744747l, 4477744774l, 44777474l, 4477747447l, 4477747474l, 4477747744l, 44777744l, 4477774447l, 4477774474l, 4477774744l, 4477777444l, 47l, 4744447777l, 4744474777l, 4744477477l, 47444777l, 4744477747l, 4744477774l, 4744744777l, 4744747477l, 47447477l, 4744747747l, 4744747774l, 474477l, 4744774477l, 47447747l, 4744774747l, 4744774774l, 47447774l, 4744777447l, 4744777474l, 4744777744l, 4747l, 4747444777l, 4747447477l, 47474477l, 4747447747l, 4747447774l, 474747l, 4747474477l, 47474747l, 4747474747l, 4747474774l, 47474774l, 4747477447l, 4747477474l, 4747477744l, 474774l, 4747744477l, 47477447l, 4747744747l, 4747744774l, 47477474l, 4747747447l, 4747747474l, 4747747744l, 47477744l, 4747774447l, 4747774474l, 4747774744l, 4747777444l, 4774l, 4774444777l, 4774447477l, 47744477l, 4774447747l, 4774447774l, 477447l, 4774474477l, 47744747l, 4774474747l, 4774474774l, 47744774l, 4774477447l, 4774477474l, 4774477744l, 477474l, 4774744477l, 47747447l, 4774744747l, 4774744774l, 47747474l, 4774747447l, 4774747474l, 4774747744l, 47747744l, 4774774447l, 4774774474l, 4774774744l, 4774777444l, 477744l, 4777444477l, 47774447l, 4777444747l, 4777444774l, 47774474l, 4777447447l, 4777447474l, 4777447744l, 47774744l, 4777474447l, 4777474474l, 4777474744l, 4777477444l, 47777444l, 4777744447l, 4777744474l, 4777744744l, 4777747444l, 4777774444l, 74l, 7444447777l, 7444474777l, 7444477477l, 74444777l, 7444477747l, 7444477774l, 7444744777l, 7444747477l, 74447477l, 7444747747l, 7444747774l, 744477l, 7444774477l, 74447747l, 7444774747l, 7444774774l, 74447774l, 7444777447l, 7444777474l, 7444777744l, 7447l, 7447444777l, 7447447477l, 74474477l, 7447447747l, 7447447774l, 744747l, 7447474477l, 74474747l, 7447474747l, 7447474774l, 74474774l, 7447477447l, 7447477474l, 7447477744l, 744774l, 7447744477l, 74477447l, 7447744747l, 7447744774l, 74477474l, 7447747447l, 7447747474l, 7447747744l, 74477744l, 7447774447l, 7447774474l, 7447774744l, 7447777444l, 7474l, 7474444777l, 7474447477l, 74744477l, 7474447747l, 7474447774l, 747447l, 7474474477l, 74744747l, 7474474747l, 7474474774l, 74744774l, 7474477447l, 7474477474l, 7474477744l, 747474l, 7474744477l, 74747447l, 7474744747l, 7474744774l, 74747474l, 7474747447l, 7474747474l, 7474747744l, 74747744l, 7474774447l, 7474774474l, 7474774744l, 7474777444l, 747744l, 7477444477l, 74774447l, 7477444747l, 7477444774l, 74774474l, 7477447447l, 7477447474l, 7477447744l, 74774744l, 7477474447l, 7477474474l, 7477474744l, 7477477444l, 74777444l, 7477744447l, 7477744474l, 7477744744l, 7477747444l, 7477774444l, 7744l, 7744444777l, 7744447477l, 77444477l, 7744447747l, 7744447774l, 774447l, 7744474477l, 77444747l, 7744474747l, 7744474774l, 77444774l, 7744477447l, 7744477474l, 7744477744l, 774474l, 7744744477l, 77447447l, 7744744747l, 7744744774l, 77447474l, 7744747447l, 7744747474l, 7744747744l, 77447744l, 7744774447l, 7744774474l, 7744774744l, 7744777444l, 774744l, 7747444477l, 77474447l, 7747444747l, 7747444774l, 77474474l, 7747447447l, 7747447474l, 7747447744l, 77474744l, 7747474447l, 7747474474l, 7747474744l, 7747477444l, 77477444l, 7747744447l, 7747744474l, 7747744744l, 7747747444l, 7747774444l, 777444l, 7774444477l, 77744447l, 7774444747l, 7774444774l, 77744474l, 7774447447l, 7774447474l, 7774447744l, 77744744l, 7774474447l, 7774474474l, 7774474744l, 7774477444l, 77747444l, 7774744447l, 7774744474l, 7774744744l, 7774747444l, 7774774444l, 77774444l, 7777444447l, 7777444474l, 7777444744l, 7777447444l, 7777474444l, 7777744444l
	};
	private void processInput() throws IOException {
		Scanner in = new Scanner(System.in);

		long n = in.nextLong();
		long res = go(n);

		System.out.printf(Locale.ENGLISH, "%d\n", res);

		in.close();
	}

	private long go(long n) {

		long res = Long.MAX_VALUE;
		
		for (int i = 0; i < nn.length; i++) {
			
			if (n <= nn[i]) {
				res = Math.min(res, nn[i]);
			}
			
		}

		return res;
	}

	public static void main(String[] args) throws Exception {
		B a = new B();
		a.processInput();
	}
}