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;
string crem(int c4, int c7) {
  string ans = "";
  for (int i = 0, _n = c4; i < _n; i++) ans += "4";
  for (int i = 0, _n = c7; i < _n; i++) ans += "7";
  return ans;
}
int main() {
  string line, ans = "";
  int n;
  cin >> line;
  n = line.length();
  if (n % 2) {
    n++;
    cout << crem(n / 2, n / 2) << "\n";
  } else if (line[0] > '7')
    cout << crem((n + 2) / 2, (n + 2) / 2) << "\n";
  else {
    int c4 = n / 2, c7 = n / 2;
    bool gtr = false;
    int locc4 = -1, locc7 = -1;
    for (int i = 0, _n = n; i < _n; i++) {
      if (gtr) {
        cout << ans + crem(c4, c7) << "\n";
        return 0;
      } else if (line[i] <= '4') {
        if (c4) {
          ans += "4";
          c4--;
          if (line[i] < '4') gtr = true;
        } else {
          ans += '7';
          c7--;
          gtr = true;
        }
      } else if (line[i] <= '7' && c7) {
        ans += "7";
        c7--;
        if (line[i] < '7') gtr = true;
      } else {
        bool ok = false;
        for (int c = i - 1; c >= 0; c--) {
          if (ans[c] == '7')
            c7++;
          else if (ans[c] == '4') {
            c4++;
            if (c7 > 0) {
              ans[c] = '7';
              c7--;
              ok = true;
              for (int j = 0, _n = c + 1; j < _n; j++) cout << ans[j];
              cout << crem(c4, c7) << "\n";
              return 0;
            }
          }
        }
        if (!ok) {
          cout << crem((n + 2) / 2, (n + 2) / 2) << "\n";
          return 0;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}