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;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int tt = 1;
  for (long long int t = 1; t <= tt; t++) {
    string s;
    cin >> s;
    long long int n = s.size();
    if (n % 2 == 0) {
      string r = "";
      for (long long int i = 1; i <= n; i++) {
        r += (i <= n / 2) ? '7' : '4';
      }
      if (s > r) {
        reverse(r.begin(), r.end());
        cout << "4" << r << "7";
      } else {
        long long int four = n / 2, seven = n / 2;
        bool flag = 0;
        r = "";
        for (long long int i = 0; i <= n - 1; i++) {
          if (s[i] < '4') {
            break;
          } else if (s[i] == '4') {
            if (four == 0) {
              break;
            }
            r += '4';
            four--;
          } else if (s[i] < '7') {
            if (seven > 0) {
              r += '7';
              seven--;
            } else {
              flag = 1;
            }
            break;
          } else if (s[i] == '7') {
            if (seven == 0) {
              flag = 1;
              break;
            }
            r += '7';
            seven--;
          } else {
            flag = 1;
            break;
          }
        }
        if (flag) {
          long long int i = r.size(), index;
          for (long long int j = i - 1; j >= 0; j--) {
            if (s[j] == '4') {
              if (seven > 0) {
                index = j;
                break;
              }
            } else {
              seven++;
            }
          }
          r = "";
          four = seven = n / 2;
          for (long long int j = 0; j <= index - 1; j++) {
            r += s[j];
            (s[j] == '4') ? four-- : seven--;
          }
          r += '7';
          seven--;
        }
        while (four--) {
          r += '4';
        }
        while (seven--) {
          r += '7';
        }
        cout << r;
      }
    } else {
      for (long long int i = 1; i <= n / 2 + 1; i++) {
        cout << "4";
      }
      for (long long int i = 1; i <= n / 2 + 1; i++) {
        cout << "7";
      }
    }
    cout << '\n';
  }
  return 0;
}