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>
int tc(char a) { return a - int('0'); }
using namespace std;
int main() {
  string st;
  cin >> st;
  int n = st.size();
  if (n & 1) {
    for (int i = 0; i < n / 2 + 1; i++) cout << '4';
    for (int i = 0; i < n / 2 + 1; i++) cout << '7';
    cout << endl;
    return 0;
  }
  bool convertir = 0;
  int cf = n / 2, cs = n / 2, uf = -1;
  string ans;
  for (int c = 0; c < n; c++) {
    int i = tc(st[c]);
    if (i < 4) {
      break;
    }
    if (i == 4) {
      if (cf == 0) {
        break;
      }
      if (cs > 0) uf = c;
      ans.push_back('4');
      cf--;
    } else {
      if (i < 7) {
        if (cs == 0) {
          convertir = 1;
          break;
        }
        ans.push_back('7');
        cs--;
        break;
      }
      if ((i == 7 && cs == 0) || i > 7) {
        convertir = 1;
        break;
      }
      ans.push_back('7');
      cs--;
    }
  }
  if (convertir) {
    string ans1;
    if (uf != -1) {
      cf = cs = n / 2;
      for (int i = 0; i < uf; i++) {
        ans1.push_back(ans[i]);
        if (ans[i] == '4') {
          cf--;
        } else {
          cs--;
        }
      }
      ans1.push_back('7');
      cs--;
      while (cf > 0) {
        ans1.push_back('4');
        cf--;
      }
      while (cs > 0) {
        ans1.push_back('7');
        cs--;
      }
      cout << ans1 << endl;
      return 0;
    }
    for (int i = 0; i < n / 2 + 1; i++) cout << '4';
    for (int i = 0; i < n / 2 + 1; i++) cout << '7';
    cout << endl;
    return 0;
  }
  while (cf > 0) {
    ans.push_back('4');
    cf--;
  }
  while (cs > 0) {
    ans.push_back('7');
    cs--;
  }
  cout << ans << endl;
  return 0;
}