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;
char s[100005];
int sum[100005], a[100005], b[100005];
int big, n, seven, four, i;
void Print(int n) {
  if (n & 1) ++n;
  for (int i = 1; i <= n / 2; i++) putchar('4');
  for (int i = 1; i <= n / 2; i++) putchar('7');
  exit(0);
}
void Write() {
  for (int i = 1; i <= n; i++) printf("%d", b[i]);
  exit(0);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  if (n & 1) Print(n);
  for (i = 1; i <= n; i++) a[i] = s[i] - '0';
  for (i = 1; i <= n; i++)
    if (a[i] != 7) break;
  if (i <= n && a[i] > 7) Print(++n);
  for (i = 1; i <= n; i++)
    if (!big) {
      if (a[i] <= 4)
        b[i] = 4, big = (a[i] < 4);
      else if (a[i] <= 7)
        b[i] = 7, big = (a[i] < 7);
      else {
        for (--i; b[i] != 4; i--)
          ;
        b[i] = 7;
        for (++i; i <= n; i++) b[i] = 4;
        break;
      }
    } else
      b[i] = 4;
  for (i = 1; i <= n; i++) four += b[i] == 4, seven += b[i] == 7;
  if (four == seven) Write();
  if (four > seven) {
    for (i = n; i && four != seven; i--)
      if (b[i] == 4) b[i] = 7, four--, seven++;
    Write();
  }
  for (i = 1; i <= n; i++) sum[i] = sum[i - 1] + (b[i] == 4);
  for (i = n; i; i--)
    if (b[i] == 4 && sum[i - 1] + (n - i) >= n / 2) {
      b[i] = 7;
      seven++;
      four--;
      for (++i; i <= n && seven != four; i++)
        if (b[i] == 7) b[i] = 4, seven--, four++;
      Write();
    }
  Print(n + 1);
}