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;
const int MAX_K = 100000;
char s[MAX_K + 4];
int ds[MAX_K + 4];
int fillds(int ds[], int p, int n4, int n7) {
  while (n4--) ds[p++] = 4;
  while (n7--) ds[p++] = 7;
  return p;
}
int rollback(int ds[], int p, int h, int n4, int n7) {
  p--;
  while (p >= 0) {
    if (ds[p] == 4) {
      n4--;
      if (n7 < h) break;
      p--;
    } else {
      n7--;
      p--;
    }
  }
  if (p < 0) return fillds(ds, 0, h + 1, h + 1);
  ds[p++] = 7, n7++;
  return fillds(ds, p, h - n4, h - n7);
}
int main() {
  scanf("%s", s);
  int k = strlen(s);
  if (k & 1) {
    int h = (k + 1) / 2;
    k = fillds(ds, 0, h, h);
  } else {
    int h = k / 2;
    int n4 = 0, n7 = 0, p = 0;
    while (p >= 0 && p < k) {
      if (s[p] < '4')
        p = fillds(ds, p, h - n4, h - n7);
      else if (s[p] == '4') {
        if (n4 < h)
          ds[p++] = 4, n4++;
        else
          p = fillds(ds, p, 0, h - n7);
      } else if (s[p] < '7') {
        if (n7 < h) {
          ds[p++] = 7, n7++;
          p = fillds(ds, p, h - n4, h - n7);
        } else
          k = p = rollback(ds, p, h, n4, n7);
      } else if (s[p] == '7') {
        if (n7 < h)
          ds[p++] = 7, n7++;
        else
          k = p = rollback(ds, p, h, n4, n7);
      } else
        k = p = rollback(ds, p, h, n4, n7);
    }
  }
  for (int i = 0; i < k; i++) putchar(ds[i] + '0');
  putchar('\n');
  return 0;
}