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>
const int inf = 0x3f3f3f3f;
const int Maxn = 100005;
using namespace std;
int read() {
  int x = 0, f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
char s[Maxn];
int len;
void dfs(int x) {
  int a = s[x] - '0' + 1;
  s[x] = a + '0';
  if (a > 7)
    dfs(x - 1);
  else
    return;
}
int main() {
  cin >> s + 1;
  len = strlen(s + 1);
  int a = 0, b = 0;
  if (len % 2 == 1) {
    for (int i = 1; i <= len / 2 + 1; i++) printf("4");
    for (int i = 1; i <= len / 2 + 1; i++) printf("7");
  } else {
    for (int i = 1; i <= len; i++) {
      if (s[i] > '7') {
        dfs(i - 1);
        break;
      }
      if (s[i] > '4' && s[i] < '7') break;
      if (s[i] >= '0' && s[i] < '4') break;
    }
    if (s[1] > '7') {
      for (int i = 1; i <= len / 2 + 1; i++) printf("4");
      for (int i = 1; i <= len / 2 + 1; i++) printf("7");
    } else {
      int s4 = 0, s7 = 0, pos;
      for (int i = 1; i <= len; i++) {
        pos = i;
        if (s[i] > '4' && s[i] < '7') {
          s[i] = '7';
          break;
        }
        if (s[i] >= '0' && s[i] < '4') {
          s[i] = '4';
          break;
        }
      }
      for (int i = 1; i <= pos; i++)
        if (s[i] == '7') s7++;
      if (s7 > len / 2) {
        bool flag = 0;
        int zz = s7;
        int zk = pos;
        for (int i = zk; i >= 1; i--) {
          if (s[i] == '4') {
            s[i] = '7';
            pos = i;
            if (zz + 1 <= len / 2) {
              flag = 1;
              break;
            }
          } else
            zz--;
        }
        if (!flag) {
          for (int i = 1; i <= len / 2 + 1; i++) printf("4");
          for (int i = 1; i <= len / 2 + 1; i++) printf("7");
          return 0;
        }
      }
      s7 = 0;
      for (int i = 1; i <= pos; i++) {
        if (s[i] == '4') s4++;
        if (s[i] == '7') s7++;
        if (s4 <= len / 2)
          printf("%c", s[i]);
        else
          printf("7");
      }
      for (int i = s4 + 1; i <= len / 2; i++) printf("4");
      for (int i = s7 + 1; i <= len / 2; i++) printf("7");
    }
  }
}