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;
void printopt(int p) {
  for (int i = p / 2; i; i--) printf("4");
  for (int i = p / 2; i; i--) printf("7");
}
char s[100000 + 2];
char s47[100000 + 2];
int n;
bool fopt(int i, int ddif47) {
  if (abs(ddif47) > n - i) return 0;
  int j = i;
  for (; j < i + (n - i - ddif47) / 2; j++) s47[j] = '4';
  for (; j < n; j++) s47[j] = '7';
  return 1;
}
bool f(int i, int dif47) {
  if (i == n) return dif47 == 0;
  switch (s[i] - '0') {
    case 0:
    case 1:
    case 2:
    case 3:
      if (fopt(i, dif47)) return 1;
      break;
    case 4:
      s47[i] = '4';
      if (f(i + 1, dif47 + 1)) return 1;
      s47[i] = '7';
      if (fopt(i + 1, dif47 - 1)) return 1;
      break;
    case 5:
    case 6:
      s47[i] = '7';
      if (fopt(i + 1, dif47 - 1)) return 1;
      break;
    case 7:
      s47[i] = '7';
      if (f(i + 1, dif47 - 1)) return 1;
      break;
    case 8:
    case 9:
      break;
  }
  return 0;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  if (n % 2)
    printopt(n + 1);
  else if (f(0, 0))
    printf("%s", s47);
  else
    printopt(n + 2);
  printf("\n");
}