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[100100];
char A[100100];
int f[100100], g[100100], ff[100100], gg[100100];
int n;
void print(int a, int b, int p) {
  for (int i = a; i < n / 2; i++) A[p++] = '4';
  for (int i = b; i < n / 2; i++) A[p++] = '7';
  A[p] = 0;
  puts(A);
}
bool can(int a, int b, int p) {
  if (a > n / 2 || b > n / 2) return 0;
  b = n / 2 - b;
  a = n / 2 - a;
  if (b) {
    if (f[p] - p < b) {
      if (g[p] == f[p]) return 0;
      return 1;
    }
  }
  if (a) {
    p += b;
    if (ff[p] - p < a && ff[p] == gg[p]) return 0;
  }
  return 1;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  int a = 0, b = 0;
  if (n & 1) {
    for (int i = 0; i <= n / 2; i++) putchar('4');
    for (int i = 0; i <= n / 2; i++) putchar('7');
    puts("");
    return 0;
  }
  int cf = n, cg = n;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] != '7') cf = i;
    if (s[i] > '7') cg = i;
    f[i] = cf;
    g[i] = cg;
  }
  cf = n, cg = n;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] != '4') cf = i;
    if (s[i] > '4') cg = i;
    ff[i] = cf;
    gg[i] = cg;
  }
  int ok = 1;
  for (int i = 0; i < n; i++) {
    if (s[i] < '4' && a + 1 - b <= n - i - 1) {
      A[i] = '4';
      print(a + 1, b, i + 1);
      return 0;
    }
    if (s[i] == '4') {
      A[i] = '4';
      if (can(a + 1, b, i + 1)) {
        a++;
        continue;
      }
    }
    if (s[i] < '7' && b + 1 - a <= n - i - 1) {
      A[i] = '7';
      print(a, b + 1, i + 1);
      return 0;
    }
    if (s[i] == '7') {
      A[i] = '7';
      if (can(a, b + 1, i + 1)) {
        b++;
        continue;
      }
    }
    ok = 0;
    break;
  }
  if (ok) {
    A[n] = 0;
    puts(A);
    return 0;
  }
  for (int i = 0; i <= n / 2; i++) putchar('4');
  for (int i = 0; i <= n / 2; i++) putchar('7');
  puts("");
  return 0;
}