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 s[1010000];
int main() {
  int i, j, k, m, n;
  scanf("%s", s);
  n = strlen(s);
  if (n % 2 == 1) {
    n = (n + 1) / 2;
    for (i = 1; i <= n; i++) putchar('4');
    for (i = 1; i <= n; i++) putchar('7');
    puts("");
  } else {
    char u = '7';
    int flag = 0;
    for (i = 0; i < n; i++) {
      if (i + i == n) u = '4';
      if (s[i] > u) {
        flag = -1;
        break;
      } else if (s[i] < u) {
        flag = 1;
        break;
      }
    }
    if (flag == -1) {
      n = (n + 2) / 2;
      for (i = 1; i <= n; i++) putchar('4');
      for (i = 1; i <= n; i++) putchar('7');
      puts("");
    } else {
      int pos = -1;
      int c4 = 0, c7 = 0;
      int f = 0;
      for (i = 0; i < n; i++) {
        if (f || s[i] <= '4') {
          if (s[i] < '4') f = 1;
          s[i] = '4';
          pos = i;
          c4++;
        } else if (s[i] <= '7') {
          if (s[i] < '7') f = 1;
          s[i] = '7';
          c7++;
        } else {
          s[i] = '4';
          s[pos] = '7';
          pos = i;
          c7++;
          f = 1;
        }
      }
      if (c7 > c4) {
        int cnt = 0;
        for (i = n - 1; i >= 0; i--) {
          if (s[i] == '7') cnt++;
          if (cnt >= (c7 - c4) / 2 + 1) break;
        }
        for (; i >= 0; i--)
          if (s[i] == '4') {
            c7++;
            c4--;
            s[i] = '7';
            break;
          }
        for (i = i + 1; i < n; i++)
          if (s[i] == '7') {
            s[i] = '4';
            c7--;
            c4++;
          }
      }
      if (c7 < c4) {
        for (i = n - 1; i >= 0; i--) {
          if (c4 > c7 && s[i] == '4') {
            s[i] = '7';
            c4--;
            c7++;
          }
        }
      }
      puts(s);
    }
  }
  scanf("%*d");
}