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.BufferedInputStream;
import java.io.IOException;
import java.util.InputMismatchException;

public class Main
{
	private boolean isFound;
	
	public void dfs(int step1, int step2, int n, String s, StringBuilder str)
	{
		if(isFound)
		{
			return;
		}
		if(step1 == n / 2 && step2 == n / 2)
		{
			if(str.toString().compareTo(s) >= 0)
			{
				isFound = true;
				System.out.println(str);
			}
			return;
		}
		if(step1 < n / 2)
		{
			str.append("4");
			dfs(step1 + 1, step2, n, s, str);
			str.deleteCharAt(str.length() - 1);
		}
		if(step2 < n / 2)
		{
			str.append("7");
			dfs(step1, step2 + 1, n, s, str);
			str.deleteCharAt(str.length() - 1);
		}
	}
	
	public void foo()
	{
		MyScanner scan = new MyScanner();
		String s = scan.next();
		int n = s.length();
		StringBuilder str = new StringBuilder();
		if(1 == n % 2)
		{
			for(int i = 0;i < (n + 1) / 2;++i)
			{
				str.append("4");
			}
			for(int i = 0;i < (n + 1) / 2;++i)
			{
				str.append("7");
			}
			System.out.println(str);
		}
		else
		{
			for(int i = 0;i < n / 2;++i)
			{
				str.append("7");
			}
			for(int i = 0;i < n / 2;++i)
			{
				str.append("4");
			}
			if(str.toString().compareTo(s) < 0)
			{
				str.delete(0, n);
				for(int i = 0;i < n / 2 + 1;++i)
				{
					str.append("4");
				}
				for(int i = 0;i < n / 2 + 1;++i)
				{
					str.append("7");
				}
				System.out.println(str);
			}
			else
			{
				str.delete(0, n);
				isFound = false;
				dfs(0, 0, n, s, str);
			}
		}
	}
	
	public static void main(String[] args)
	{
		new Main().foo();
	}
	
	class MyScanner
	{
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    BufferedInputStream bis = new BufferedInputStream(System.in);

	    public int read() 
	    {
	        if (-1 == numChars)
	        {
	        	throw new InputMismatchException();
	        }
	        if (curChar >= numChars)
	        {
	            curChar = 0;
	            try 
	            {
	                numChars = bis.read(buf);
	            }
	            catch (IOException e)
	            {
	                throw new InputMismatchException();
	            }
	            if (numChars <= 0)
	            {
	            	return -1;
	            }
	        }
	        return buf[curChar++];
	    }

	    public int nextInt() 
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        int sgn = 1;
	        if (c == '-') 
	        {
	            sgn = -1;
	            c = read();
	        }
	        int res = 0;
	        do 
	        {
	            if (c < '0' || c > '9')
	            {
	            	throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }
	    
	    public String next()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        StringBuilder res = new StringBuilder();
	        do 
	        {
	            res.appendCodePoint(c);
	            c = read();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    private boolean isSpaceChar(int c) 
	    {
	        return ' ' == c || '\n' == c || '\r' == c || '\t' == c || -1 == c;
	    }
	}
}