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;
void exceed(int j) {
  int i;
  j = j / 2;
  for (i = 0; i < j; i++) cout << 4;
  for (i = 0; i < j; i++) cout << 7;
}
int main() {
  int sta[20];
  int i, j, k, l, four = 0, seven = 0;
  ;
  bool f = true;
  char s[20];
  scanf("%s", s);
  j = strlen(s);
  if (j % 2) {
    exceed(j + 1);
    return 0;
  }
  i = 0;
  while (f && s[i] != 0) {
    switch (s[i]) {
      case '0':
      case '1':
      case '2':
      case '3':
        f = false;
        sta[i] = 1;
        four++;
        for (k = i + 1; s[k] != 0; k++) {
          if (four < j / 2) {
            sta[k] = 1;
            four++;
          } else {
            sta[k] = 2;
            seven++;
          }
        }
        break;
      case '4':
        sta[i] = 1;
        four++;
        break;
      case '5':
      case '6':
        f = false;
        sta[i] = 2;
        for (k = i + 1; s[k] != 0; k++) {
          if (four < j / 2) {
            sta[k] = 1;
            four++;
          } else {
            sta[k] = 2;
            seven++;
          }
        }
        break;
      case '7':
        if (seven < j / 2) {
          sta[i] = 2;
          seven++;
          break;
        }
      case '8':
      case '9':
        f = false;
        sta[i] = 1;
        if (i == 0) {
          exceed(j + 2);
          return 0;
        }
        k = i - 1;
        while (sta[k] == 2) {
          sta[k] = 1;
          k--;
          if (k < 0) {
            exceed(j + 2);
            return 0;
          }
        }
        sta[k] = 2;
        four = 0;
        seven = 0;
        for (l = 0; l <= k; l++) {
          if (sta[l] == 1)
            four++;
          else {
            seven++;
            if (seven > j / 2) {
              exceed(j + 2);
              return 0;
            }
          }
        }
        for (; s[l] != 0; l++) {
          if (four < j / 2) {
            sta[l] = 1;
            four++;
          } else {
            sta[l] = 2;
            seven++;
          }
        }
    }
    i++;
  }
  i = 0;
  while (s[i] != 0) {
    switch (sta[i]) {
      case 1:
        cout << 4;
        break;
      case 2:
        cout << 7;
        break;
    }
    i++;
  }
  return 0;
}