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.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class A {

	public static void main(String[] args) throws IOException 
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		String s = sc.next();

		if((s.length() & 1) == 1)
			out.println(construct(s.length() + 1));
		else
		{
			char[] t = new char[s.length()];
			int rem4 = s.length() / 2, rem7 = rem4;
			boolean lower = false;
			for(int i = 0; i < s.length(); ++i)
			{
				if(lower)
					t[i] = rem4 > 0 ? '4' : '7';
				else if(rem4 > 0 && s.charAt(i) <= '4')
					t[i] = '4';
				else if(rem7 > 0 && s.charAt(i) <= '7') 
					t[i] = '7';
				else
				{
					int j = i - 1;
					while(j >= 0 && (rem7 == 0 || t[j] == '7'))
					{
						if(t[j--] == '7')
							++rem7;
						else
							++rem4;
					}
					if(j == -1)
					{
						rem4 = rem7 = -1;
						break;
					}
					t[j] = '7';
					++rem4;
					i = j;	
				}
					
				if(t[i] == '4')
					--rem4;
				else
					--rem7;
				lower |= t[i] > s.charAt(i);
			}
			if(rem4 != 0 || rem7 != 0)
				t = construct(s.length() + 2).toCharArray();
			out.println(t);
		}

		out.flush();
		out.close();
	}

	static String construct(int n)
	{
		int k = n / 2;
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < k; ++i)
			sb.append("4");
		for(int i = 0; i < k; ++i)
			sb.append("7");
		return sb.toString();
	}

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(FileReader r){	br = new BufferedReader(r);}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();}


	}
}