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

Solution:
#include <bits/stdc++.h>
int N, four[100005], svn[100005];
char buf[100005];
int main() {
  int i, j, k, a = 0, b = 0;
  scanf("%s", buf), N = strlen(buf);
  if (N & 1) {
    for (i = N; i; i--) buf[i] = buf[i - 1];
    buf[0] = '0';
    buf[++N] = 0;
  }
  for (i = 0; i < N; i++) {
    four[i] = a, svn[i] = b;
    if (buf[i] == '4')
      a++;
    else if (buf[i] == '7')
      b++;
  }
  if (a + b == N && a == b) {
    puts(buf);
    return 0;
  }
  for (i = N; i--;) {
    a = four[i], b = svn[i];
    if (a + b != i || a > N / 2 || b > N / 2) continue;
    k = 0;
    if (buf[i] < '4' && a < N / 2)
      k = 4;
    else if (buf[i] < '7' && b < N / 2)
      k = 7;
    if (!k) continue;
    for (j = 0; j < i; j++) printf("%c", buf[j]);
    printf("%c", '0' + k);
    if (k == 4)
      a++;
    else
      b++;
    for (j = i + 1; j < N; j++) {
      if (a < N / 2)
        a++, printf("4");
      else
        b++, printf("7");
    }
    return 0;
  }
  for (i = 0; i < N / 2 + 1; i++) printf("4");
  for (i = 0; i < N / 2 + 1; i++) printf("7");
}