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>
char a[100005], b[100005];
int p4[100005], c[100005];
int main() {
  int i, j, c4 = 0, l, h, c7 = 0, f = 0;
  scanf("%s", a);
  l = strlen(a);
  if (l & 1) {
    h = (l + 1) >> 1;
    for (i = 0; i < h; i++) putchar(52);
    for (i = 0; i < h; i++) putchar(55);
    return 0;
  } else {
    h = l >> 1;
    for (i = 0; i < l; i++) {
      if (a[i] <= 52) {
        c4++;
        if (c4 > h) {
          b[i] = 55;
          c4--, c7++;
          break;
        } else {
          b[i] = 52;
          if (a[i] < 52) break;
          p4[c4] = i;
          c[c4] = c7;
        }
      } else if (a[i] <= 55) {
        c7++;
        if (c7 > h) {
          while (c4 > 0 && c[c4] >= h) c4--;
          if (c4 == 0) {
            f = 1;
            break;
          }
          b[i = p4[c4]] = 55;
          c7 = c[c4] + 1;
          c4--;
          break;
        } else {
          b[i] = 55;
          if (a[i] < 55) break;
        }
      } else {
        while (c4 > 0 && c[c4] >= h) c4--;
        if (c4 == 0) {
          f = 1;
          break;
        }
        b[i = p4[c4]] = 55;
        c7 = c[c4] + 1;
        c4--;
        break;
      }
    }
  }
  if (f) {
    i = h + 1;
    while (i--) putchar(52);
    i = h + 1;
    while (i--) putchar(55);
  } else {
    if (i == l) i--;
    for (j = 0; j <= i; j++) putchar(b[j]);
    i = h - c4;
    while (i--) putchar(52);
    i = h - c7;
    while (i--) putchar(55);
  }
  return 0;
}