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 s1[100100];
int num[100100];
char res[100100];
void out(int n) {
  for (int i = (0); i < (n); ++i)
    if (i < n / 2)
      printf("4");
    else
      printf("7");
  printf("\n");
}
int n;
bool r(int p, int cnt1, int cnt2, bool f) {
  if (p == n) {
    if ((cnt1 == 0) && (cnt2 == 0)) return true;
    return false;
  }
  if (f) {
    if (cnt1 > 0) {
      res[p] = '4';
      bool ff = r(p + 1, cnt1 - 1, cnt2, f);
      if (ff) return true;
    } else {
      res[p] = '7';
      bool ff = r(p + 1, cnt1, cnt2 - 1, f);
      if (ff) return true;
    }
    return false;
  }
  if (s[p] <= '4') {
    if (cnt1 > 0) {
      res[p] = '4';
      bool f1 = false;
      if (s[p] < '4') f1 = true;
      bool ff = r(p + 1, cnt1 - 1, cnt2, f1);
      if (ff) return true;
    }
  }
  if (s[p] <= '7') {
    if (cnt2 > 0) {
      res[p] = '7';
      bool f1 = false;
      if (s[p] < '7') f1 = true;
      bool ff = r(p + 1, cnt1, cnt2 - 1, f1);
      if (ff) return true;
    }
  }
  return false;
}
int main() {
  scanf("%s", &s);
  n = strlen(s);
  if (n & 1) {
    out(n + 1);
    return 0;
  }
  for (int i = (0); i < (n); ++i)
    if (i < n / 2)
      s1[i] = '7';
    else
      s1[i] = '4';
  bool f = true;
  for (int i = (0); i < (n); ++i)
    if (s1[i] > s[i])
      break;
    else if (s[i] > s1[i]) {
      f = false;
      break;
    }
  int cnt1 = 0, cnt2 = 0;
  for (int i = (0); i < (n); ++i) {
    if (s[i] == '4')
      cnt1++;
    else if (s[i] == '7')
      cnt2++;
  }
  if (!f) {
    out(n + 2);
    return 0;
  }
  if ((cnt1 + cnt2 == n) && (cnt1 == cnt2)) {
    for (int i = (0); i < (n); ++i) printf("%c", s[i]);
    printf("\n");
    return 0;
  }
  f = r(0, n / 2, n / 2, false);
  for (int i = (0); i < (n); ++i) printf("%c", res[i]);
  printf("\n");
  return 0;
}