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.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;


public class Numbers {
    public static void main(String args[]) {
        new Numbers();
    }
    
    public Numbers() {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        
        long N = Long.parseLong(s);
        List<Long> list = new LinkedList<Long>();
        for (int i = 2; i <= 10; i += 2) {
            if (i == 2)
                for (int j = 0; j < i; j++) {
                    char[] t = new char[i];
                    Arrays.fill(t, '4');
                    t[j] = '7';
                    list.add(Long.parseLong(new String(t)));
                }
            if (i == 4)
                for (int j = 0; j < i; j++)
                    for (int k = j + 1; k < i; k++){
                    char[] t = new char[i];
                    Arrays.fill(t, '4');
                    t[j] = '7';
                    t[k] = '7';
                    list.add(Long.parseLong(new String(t)));
                }
            if (i == 6)
                for (int j = 0; j < i; j++)
                for (int k = j + 1; k < i; k++)
                for (int l = k + 1; l < i; l++) {
                    char[] t = new char[i];
                    Arrays.fill(t, '4');
                    t[j] = '7';
                    t[k] = '7';
                    t[l] = '7';
                    list.add(Long.parseLong(new String(t)));
                }
            if (i == 8)
                for (int j = 0; j < i; j++)
                for (int k = j + 1; k < i; k++)
                for (int l = k + 1; l < i; l++)
                for (int m = l + 1; m < i; m++){
                    char[] t = new char[i];
                    Arrays.fill(t, '4');
                    t[j] = '7';
                    t[k] = '7';
                    t[l] = '7';
                    t[m] = '7';
                    list.add(Long.parseLong(new String(t)));
                }
            if (i == 10)
                for (int j = 0; j < i; j++)
                for (int k = j + 1; k < i; k++)
                for (int l = k + 1; l < i; l++)
                for (int m = l + 1; m < i; m++)
                for (int q = m + 1; q < i; q++) {
                    char[] t = new char[i];
                    Arrays.fill(t, '4');
                    t[j] = '7';
                    t[k] = '7';
                    t[l] = '7';
                    t[m] = '7';
                    t[q] = '7';
                    list.add(Long.parseLong(new String(t)));
                }
        }
        Collections.sort(list);
        for (Long l : list)
            if (l >= N) {
                System.out.println(l);
                break;
            }
    }
}