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;
template <class T>
void check_max(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
void check_min(T& a, T b) {
  if (a > b) a = b;
}
const int MAXL = 100000 + 10;
char d[MAXL];
int l;
int main() {
  scanf("%s", d);
  l = strlen(d);
  if (l % 2 == 1) {
    l++;
    for (int _t = l / 2, k = 0; k < _t; k++) putchar('4');
    for (int _t = l / 2, k = 0; k < _t; k++) putchar('7');
    putchar('\n');
    return 0;
  }
  int cnt[10];
  memset(cnt, 0, sizeof(cnt));
  for (int _t = l, i = 0; i < _t; i++) cnt[d[i] - '0']++;
  bool found = false;
  int i = l;
  for (; i >= 0; i--) {
    if (cnt[4] + cnt[7] == i) {
      int rest = l - cnt[4] - cnt[7];
      if (rest == 0) {
        if (cnt[4] == cnt[7]) {
          for (int _t = i, k = 0; k < _t; k++) putchar(d[k]);
          putchar('\n');
          found = true;
          break;
        }
      } else {
        if (d[i] - '0' < 4) {
          int a = cnt[4] + 1, b = cnt[7];
          if (a <= l / 2 && b <= l / 2) {
            for (int _t = i, k = 0; k < _t; k++) putchar(d[k]);
            putchar('4');
            for (int _t = l / 2 - a, k = 0; k < _t; k++) putchar('4');
            for (int _t = l / 2 - b, k = 0; k < _t; k++) putchar('7');
            putchar('\n');
            found = true;
            break;
          }
        }
        if (d[i] - '0' < 7) {
          int a = cnt[4], b = cnt[7] + 1;
          if (a <= l / 2 && b <= l / 2) {
            for (int _t = i, k = 0; k < _t; k++) putchar(d[k]);
            putchar('7');
            for (int _t = l / 2 - a, k = 0; k < _t; k++) putchar('4');
            for (int _t = l / 2 - b, k = 0; k < _t; k++) putchar('7');
            putchar('\n');
            found = true;
            break;
          }
        }
      }
    }
    if (i > 0) cnt[d[i - 1] - '0']--;
  }
  if (!found) {
    l += 2;
    for (int _t = l / 2, k = 0; k < _t; k++) putchar('4');
    for (int _t = l / 2, k = 0; k < _t; k++) putchar('7');
    putchar('\n');
  }
  return 0;
}