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.*;
import java.util.*;
public class Template {
	//static int cnt=0;
static Scanner sc=new Scanner(System.in);
	static ArrayList<Integer> v=new ArrayList();;
	static int max=0;
	static String f3="";
	static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 
	
	public static void main (String[] args) throws java.lang.Exception{
		long n=sc.nextLong();
		String s=String.valueOf(n);
		
		int z=s.length();
		if(z%2!=0) {
			z=z+1;
			oddcase(z);
			}
		else {
	 String f=check(n,z);
	 if(n>Long.parseLong(f)) {
			oddcase(z+2);
		}
	 else if(n<Long.parseLong(f3))
		 System.out.println(f3);
	 
		
			else {
			
	for(long i=n;;i++) {
		String c=String.valueOf(i);
		boolean p=true;
		int c4=0,c7=0;
		for(int j=0;j<c.length();j++) {
			if(c.charAt(j)=='4')
				c4++;
			else if(c.charAt(j)=='7')
				c7++;
			else {
				p=false;
			break;
			}
		}
		if(!p) {
			continue;
		}
		else if(c4==c7){
			System.out.println(c);
			break;
		}
		else {
			//System.out.println("here");
			continue;
		}
	}
}

}
	}
	
	
	public static void oddcase(int z) {
		
		
			

		String f="";
		String f1="";
		String f2="";
		for(int i=1;i<=z/2;i++){
			f1+="4";
		}
		for(int i=1;i<=z/2;i++){
			f2+="7";
		}
		System.out.println(f1+f2);
		}

		
	public static String check(long n, int z) {

		String f="";
		String f1="";
		String f2="";
		for(int i=1;i<=z/2;i++){
			f1+="4";
		}
		for(int i=1;i<=z/2;i++){
			f2+="7";
		}
		f3=f1+f2;
		return (f2+f1);
	
		}
	
	
//}
	
	
	
	
	
		
	
	
	

		
	
	




	
	

		
		
	
		
	

	
	
	

		
	
	
	
	
static long gcd(long a,long b) {
		
	
		if(b==0) {
		return a;
		}
			
		
	return gcd(b,a%b);
	
	}
	
	
	
	
	
	public static int s2i(String s) {
		return Integer.parseInt(s);
	}
	

	
	
	public static int LeastIntFn(int a,int b) {
		if((b%a)==0) {
			return (int)b/a;
		}
		return (int)(b/a)+1;
	}
	
	
	
	public static ArrayList<Long> arrInpLong(int n){
		ArrayList<Long> arr=new ArrayList();
		for(int i=0;i<n;i++) {
		arr.add(sc.nextLong());	
		}
		return arr;
	}
	public static ArrayList<String> arrInpStr(int n){
		ArrayList<String> arr=new ArrayList();
		for(int i=0;i<n;i++) {
					arr.add(sc.nextLine());	
		}
		return arr;
	}
	
	public static ArrayList<Integer> arrInpInt(int n){
		ArrayList<Integer> arr=new ArrayList();
		for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			if(k>max)
				max=k;
		arr.add(k);	
		}
		return arr;
	}
	
	
	public static void printArrInt(ArrayList<Integer> arr) {
		for(int i=0;i<arr.size();i++) {
			System.out.print(arr.get(i)+" ");
	}	
		}
	
	
	public static int min(int a,int b,int c) {
		int min1=Math.min(a, b);
		return Math.min(min1,c);
	}
}