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 PYTHON):

Solution:
#!/usr/bin/python

import sys
import math

if __name__=="__main__":
    n = sys.stdin.readline()[:-1]
    if len(n) % 2 == 1:
        n = '0' + n
    
    if int(n[0]) > 7:
        n = "00"+n

    n = [int(v) for v in n]

    l = len(n) / 2
    ans = [4] * l + [7] * l
    j = l
    last_four = -1
    flag = True
    for i in range(0, l*2):
        if ans[i] > n[i]:
            break
        elif ans[i] < n[i]:
            if ans[i] == 4 and j < l * 2:
                ans[i],ans[j] = ans[j],ans[i]
                j += 1
            if ans[i] > n[i]:
                break
            elif ans[i] < n[i]:
                if last_four == -1:
                    flag = False
                    break
                ans[last_four] = 7
                c4,c7=l,l
                for k in range(0,l*2):
                    if k <= last_four:
                        if ans[k] == 4:
                            c4 -= 1
                        else:
                            c7 -= 1
                    else:
                        if c4 > 0:
                            c4 -= 1
                            ans[k] = 4
                        else:
                            ans[k] = 7
                break
        
        if ans[i] == 4 and j < l * 2:
            last_four = max(last_four, i)
    
    if not flag:
        print '4'*(l+1)+'7'*(l+1)
    else:
        for c in ans:
            sys.stdout.write(str(c))
        sys.stdout.write('\n')