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>
using namespace std;
char n[100010];
char a[100010];
int main() {
  scanf("%s", n);
  int l = strlen(n);
  if (l % 2 == 1) {
    for (int i = 0; i < (l + 1) / 2; i++) putchar('4');
    for (int i = 0; i < (l + 1) / 2; i++) putchar('7');
    printf("\n");
    return 0;
  } else {
    int m4 = l / 2;
    int m7 = l / 2;
    bool eq = true;
    memset(a, 0, sizeof(a));
    for (int i = 0; i < l; i++) {
      if (!eq) {
        if (m4 > 0) {
          a[i] = '4';
          m4--;
        } else {
          a[i] = '7';
          m7--;
        }
      } else {
        if (n[i] <= '4' && m4 > 0) {
          a[i] = '4';
          m4--;
          if (n[i] < '4') eq = false;
        } else if (n[i] <= '4' && m4 == 0) {
          a[i] = '7';
          m4--;
          eq = false;
        } else if (n[i] <= '7' && m7 > 0) {
          a[i] = '7';
          m7--;
          if (n[i] < '7') eq = false;
        } else {
          for (i--; i >= 0; i--) {
            if (a[i] == '4')
              m4++;
            else
              m7++;
            if (a[i] == '4' && m7 > 0) {
              a[i] = '7';
              m7--;
              eq = false;
              break;
            }
          }
          if (i == -1) {
            for (i = 0; i < l / 2 + 1; i++) a[i] = '4';
            for (; i < l + 2; i++) a[i] = '7';
            break;
          }
        }
      }
    }
    printf("%s\n", a);
  }
}