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 long long MOD = 1e9 + 7;
const int N = 1e6 + 20;
int n, l0, l;
char f[N];
char g[N];
void init() {
  scanf("%s", &f);
  n = strlen(f);
}
bool pd() {
  for (int i = 0; i < n / 2; i++)
    if (f[i] != '7') {
      if (f[i] > '7') return false;
      return true;
    }
  for (int i = n / 2; i < n; i++)
    if (f[i] != '4') {
      if (f[i] > '4') return false;
      return true;
    }
  return true;
}
void work() {
  if (n % 2 == 1) {
    n++;
    for (int i = 1; i <= n / 2; i++) printf("4");
    for (int i = 1; i <= n / 2; i++) printf("7");
    return;
  }
  if (!pd()) {
    n += 2;
    for (int i = 1; i <= n / 2; i++) printf("4");
    for (int i = 1; i <= n / 2; i++) printf("7");
    return;
  }
  bool sign = false;
  int cnt = 0, pos = -1, p2;
  for (int i = 0; i < n; i++) {
    if (sign) {
      f[i] = '4';
      continue;
    }
    if (f[i] == '4') {
      pos = i;
      continue;
    }
    if (f[i] == '7') {
      continue;
    }
    if (f[i] < '4') {
      f[i] = '4';
      sign = true;
      continue;
    }
    if (f[i] < '7') {
      f[i] = '7';
      sign = true;
      continue;
    }
    if (f[i] > '7') {
      f[pos] = '7';
      i = pos;
      sign = true;
    }
  }
  cnt = 0;
  for (int i = 0; i < n; i++)
    if (f[i] == '7') cnt++;
  if (cnt > n / 2) {
    cnt = 0;
    f[n] = '4';
    for (int i = 0; i <= n; i++) {
      if (f[i] == '7')
        cnt++;
      else {
        if (cnt >= n / 2) {
          f[pos] = '7';
          for (int j = pos + 1; j < n; j++) f[j] = '4';
          break;
        }
        pos = i;
      }
    }
    cnt = 0;
    for (int i = 0; i < n; i++)
      if (f[i] == '7') cnt++;
  }
  for (int i = n - 1; i >= 0; i--)
    if (f[i] == '4') {
      if (cnt >= n / 2) {
        break;
      }
      cnt++;
      f[i] = '7';
    }
  f[n] = '\0';
  printf("%s\n", f);
}
int main() {
  init();
  work();
  return 0;
}