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 N = 110000;
char txt[N];
int czworki[N], siodemki[N];
int main() {
  scanf("%s", txt);
  int n = strlen(txt);
  if (n % 2 == 1) {
    for (int i = (n - 1); i >= (0); --i) txt[i + 1] = txt[i];
    txt[0] = '0';
    n++;
    txt[n] = 0;
  }
  int a = 0, b = 0;
  for (int i = 0; i < (n); ++i) {
    czworki[i] = a;
    siodemki[i] = b;
    if (txt[i] == '4') a++;
    if (txt[i] == '7') b++;
  }
  if (a + b == n && a == b) {
    puts(txt);
    return 0;
  }
  for (int i = (n - 1); i >= (0); --i) {
    a = czworki[i];
    b = siodemki[i];
    if (a + b != i || a > n / 2 || b > n / 2) continue;
    int co = -1;
    if (txt[i] < '4' && (a + 1) <= n / 2)
      co = 4;
    else if (txt[i] < '7' && (b + 1) <= n / 2)
      co = 7;
    if (co == -1) continue;
    for (int j = 0; j < (i); ++j) putchar(txt[j]);
    putchar('0' + co);
    if (co == 4)
      a++;
    else
      b++;
    for (int j = 0; j < (n - (i + 1)); ++j) {
      if (a + 1 <= n / 2)
        putchar('4'), a++;
      else
        putchar('7');
    }
    puts("");
    return 0;
  }
  for (int i = 0; i < (n / 2 + 1); ++i) putchar('4');
  for (int i = 0; i < (n / 2 + 1); ++i) putchar('7');
  puts("");
  return 0;
}