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;
inline bool eq(double a, double b) { return fabs(a - b) < 1e-9; }
const long long int inf = 1e15;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
int n;
string str;
string sol(int n) {
  string ans;
  for (int i = (0); i < (n); i++) {
    ans = ans + (i < n / 2 ? "4" : "7");
  }
  return ans;
}
void solve(int i, int c4, int c7) {
  int j = i + 1;
  for (int k = (j); k < (n); k++) {
    str[k] = '4';
    c4++;
  }
  for (int k = (n - 1); k >= (i + 1); k--) {
    if (c4 > c7) {
      str[k] = '7';
      c4--;
      c7++;
    } else {
      break;
    }
  }
  cout << str << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> str;
  n = str.length();
  if (n & 1) {
    cout << sol(n + 1) << endl;
  } else {
    int ind = -1, c4 = 0, c7 = 0;
    for (int i = (0); i < (n); i++) {
      if (str[i] > '7') {
        if (ind == -1) {
          cout << sol(n + 2) << endl;
          return 0;
        } else {
          str[ind] = '7';
          str[i] = '4';
          c7++;
          if (abs(c4 - c7) > n - i - 1) {
            cout << sol(n + 2) << endl;
            return 0;
          } else {
            solve(i, c4, c7);
            return 0;
          }
        }
      } else if (str[i] != '4' && str[i] != '7') {
        if (str[i] < '4') {
          str[i] = '4';
          c4++;
        } else {
          str[i] = '7';
          c7++;
        }
        if (abs(c4 - c7) > n - i - 1) {
          cout << sol(n + 2) << endl;
          return 0;
        } else {
          solve(i, c4, c7);
          return 0;
        }
      } else {
        if (str[i] == '4') {
          ind = i;
          c4++;
        } else
          c7++;
      }
    }
    if (c4 > c7) {
      for (int i = (ind); i >= (0); i--) {
        if (c4 > c7) {
          str[i] = '7';
          c4--;
          c7++;
        } else
          break;
      }
      cout << str << endl;
    } else if (c7 > c4) {
      int cc4 = 0, cc7 = 0;
      for (int i = 0; i <= ind; i++) {
        if (str[i] == '4')
          cc4++;
        else
          cc7++;
      }
      c4 = cc4, c7 = cc7;
      for (int i = (ind); i >= (0); i--) {
        if (str[i] == '4') {
          if (abs(c4 - c7 - 1) <= n - i - 1) {
            str[i] = '7';
            c4--;
            c7++;
            solve(i, c4, c7);
            return 0;
          }
          c4--;
        } else
          c7--;
      }
      cout << sol(n + 2) << endl;
    } else
      cout << str << endl;
  }
  return 0;
}