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[100004];
char b[100004];
int make(char b[], int len) {
  int i, j, k;
  while (1) {
    k = 0;
    for (i = 0; i < len; i++)
      if (b[i] == '7') k++;
    if (k == len / 2)
      return 0;
    else if (k < len / 2) {
      for (i = len - 1; i >= 0; i--) {
        if (b[i] == '4') k++;
        b[i] = '7';
        if (k == len / 2) return 0;
      }
    } else {
      for (i = len - 1; i >= 0; i--)
        if (b[i] == '7') break;
      for (; i >= 0; i--) {
        if (b[i] == '4')
          break;
        else
          b[i] = '4';
      }
      if (i < 0) return 1;
      b[i] = '7';
    }
  }
}
int main() {
  int i, j, k, l;
  int len;
  scanf("%s", a);
  len = strlen(a);
  j = 0;
  if ((len % 2) == 1) {
    for (i = 0; i <= len / 2; i++) printf("4");
    for (i = 0; i <= len / 2; i++) printf("7");
    printf("\n");
  } else {
    j = 0;
    l = 0;
    for (i = 0; i < len; i++) {
      if (a[i] < '4') {
        for (; i < len; i++) b[i] = '4';
      } else if (a[i] == '4') {
        b[i] = '4';
      } else if (a[i] < '7') {
        b[i] = '7';
        for (i = i + 1; i < len; i++) b[i] = '4';
      } else if (a[i] == '7') {
        b[i] = '7';
      } else {
        for (k = i - 1; k >= 0; k--)
          if (b[k] == '4') break;
        if (k < 0) {
          l = 1;
          break;
        } else {
          b[k] = '7';
          for (k = k + 1; k < len; k++) {
            b[k] = '4';
          }
          i = len;
        }
      }
    }
    l = make(b, len);
    if (l == 1) {
      for (i = 0; i < len / 2 + 1; i++) printf("4");
      for (i = 0; i < len / 2 + 1; i++) printf("7");
    } else {
      b[len] = 0;
      printf("%s", b);
    }
    printf("\n");
  }
  return 0;
}