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

}