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;
import java.io.PrintWriter;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 *
 * @author User
 */
public class Codeforces {

    /**
     * @param args the command line arguments
     */
      static ArrayList<Long> list = new ArrayList<Long>();
 
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        Scanner in = new Scanner(System.in);
        Integer J = Integer.parseInt(bf.readLine());
        calc("");
 
 
        Collections.sort(list);
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) >= J) {
                System.out.println(list.get(i));
                break;
            }
        }
 
    }
 
    static public int binarySearch(int value, List<Integer> list) {
        int left = 0, right = list.size() - 1, mid;
        while (left <= right) {
            mid = (left + right) / 2;
            if (Integer.valueOf(list.get(mid)) >= value) {
                right = mid - 1;
            } else if (Integer.valueOf(list.get(mid)) < value) {
                left = mid + 1;
            } else {
                return mid;
            }
        }
 
        return -1;
    }
 
    public static void calc(String lk) {
        if (lk.length() > 10) 
            return;
 
        if (lk.replaceAll("4", "").length() == lk.replaceAll("7", "").length() && lk.length()>0) 
            list.add(Long.parseLong(lk));
 
        calc(lk + "4");
        calc(lk + "7");
    }
}