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;
template <typename T>
inline bool eps_dayu(const T &a, const T &b) {
  return (a - b) > 1e-10 ? 1 : 0;
}
template <typename T>
inline bool eps_dengyu(const T &a, const T &b) {
  if (a - b > 1e-10 || b - a > 1e-10) return 0;
  return 1;
}
template <typename T>
inline bool eps_xiaoyu(const T &a, const T &b) {
  return b - a > 1e-10 ? 1 : 0;
}
string x, y;
bool solve(int t, int cntx, int cnty) {
  if (cntx == 0 && cnty == 0) return 1;
  if (cntx) {
    if (x[t] < '4') {
      int m = t;
      for (int i = 0; i < cntx; i++) y[m++] = '4';
      for (int i = 0; i < cnty; i++) y[m++] = '7';
      return 1;
    } else if (x[t] == '4' && solve(t + 1, cntx - 1, cnty)) {
      y[t] = '4';
      return 1;
    }
  }
  if (cnty) {
    if (x[t] < '7') {
      int m = t;
      y[m++] = '7';
      cnty--;
      for (int i = 0; i < cntx; i++) y[m++] = '4';
      for (int i = 0; i < cnty; i++) y[m++] = '7';
      return 1;
    } else if (x[t] == '7' && solve(t + 1, cntx, cnty - 1)) {
      y[t] = '7';
      return 1;
    }
  }
  return 0;
}
int main() {
  cin >> x;
  int len = x.length();
  int tt = len % 2;
  if (tt) x = "0" + x;
  while (true) {
    y = x;
    int len = x.length() / 2;
    if (solve(0, len, len)) {
      cout << y << endl;
      return 0;
    }
    x = "00" + x;
  }
  return 0;
}