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.IOException;
import java.io.InputStreamReader;


public class Round77B {
	int N;
	String str;
	
	long[] veryHappyNumbers = {47l,74l,4477l,4747l,4774l,7447l,7474l,7744l,444777l,447477l,447747l,447774l,474477l,474747l,474774l,477447l,477474l,477744l,744477l,744747l,744774l,747447l,747474l,747744l,774447l,774474l,774744l,777444l,44447777l,44474777l,44477477l,44477747l,44477774l,44744777l,44747477l,44747747l,44747774l,44774477l,44774747l,44774774l,44777447l,44777474l,44777744l,47444777l,47447477l,47447747l,47447774l,47474477l,47474747l,47474774l,47477447l,47477474l,47477744l,47744477l,47744747l,47744774l,47747447l,47747474l,47747744l,47774447l,47774474l,47774744l,47777444l,74444777l,74447477l,74447747l,74447774l,74474477l,74474747l,74474774l,74477447l,74477474l,74477744l,74744477l,74744747l,74744774l,74747447l,74747474l,74747744l,74774447l,74774474l,74774744l,74777444l,77444477l,77444747l,77444774l,77447447l,77447474l,77447744l,77474447l,77474474l,77474744l,77477444l,77744447l,77744474l,77744744l,77747444l,77774444l,4444477777l};
	
	

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Round77B task = new Round77B();
		task.getData();
		task.getSolution();
//		for(long i=0l;i<10000000000l;i++){
//			if(isVeryHappy(i)){
//				System.out.print(i+"l,");
//			}
//		}
	}

	private void getSolution() {
		
		char[] number = str.toCharArray();
		if(number.length%2==1){
			System.out.println(getMinHappyNumber(number.length/2+1,number.length/2+1));
		}else{
			
			for(int i=0;i<veryHappyNumbers.length;i++){
				if(N==veryHappyNumbers[i]){
					System.out.println(N);
					break;
				}else if(N<veryHappyNumbers[i]){
					System.out.println(veryHappyNumbers[i]);
					break;
				}
			}
		}
		
	}
	
	String getMinHappyNumber(int foursCount, int sevensCount){
		StringBuffer strb = new StringBuffer("");
		for(int i=0;i<foursCount;i++){
			strb.append("4");
		}
		for(int i=0;i<sevensCount;i++){
			strb.append("7");
		}
		return strb.toString();
	}
	
	
	static boolean isVeryHappy(long numberInt){
		char[] number = Long.toString(numberInt).toCharArray();
		int four = 0;
		int seven = 0;
		for(int i=0;i<number.length;i++){
			if(number[i]=='7'){
				seven++;
			}else if(number[i]=='4'){
				four++;
			}else{
				return false;
			}
		}
		if(seven==four){
			return true;
		}else{
			return false;
		}
	}

	private void getData() throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		str = br.readLine();
		N = Integer.parseInt(str);
	}

}