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;
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
inline int GCD(int x, int y) {
  int r = x % y;
  while (r) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
const int N = 1e6 + 69;
string p;
int f, se;
string t;
string s;
void go(int pos, int four, int seven, bool tight) {
  if (seven > (int)s.size() / 2 || four > (int)s.size() / 2) {
    return;
  }
  if (pos == (int)s.size()) {
    if (p == "") {
      p = t;
    }
    return;
  }
  if (tight == 1) {
    if (s[pos] - '0' == 4 || s[pos] - '0' == 7) {
      if (s[pos] - '0' == 4) {
        t[pos] = '4';
        go(pos + 1, four + 1, seven, 1);
        if (p != "") return;
        t[pos] = '7';
        go(pos + 1, four, seven + 1, 0);
        if (p != "") return;
      }
      if (p != "") return;
      if (s[pos] - '0' == 7) {
        t[pos] = '7';
        go(pos + 1, four, seven + 1, 1);
      }
      if (p != "") return;
    } else if (s[pos] - '0' < 4) {
      t[pos] = '4';
      go(pos + 1, four + 1, seven, 0);
      t[pos] = '7';
      go(pos + 1, four, seven + 1, 0);
    } else if (s[pos] - '0' < 7) {
      t[pos] = '7';
      go(pos + 1, four, seven + 1, 0);
    }
  } else {
    t[pos] = '4';
    go(pos + 1, four + 1, seven, 0);
    if (p != "") return;
    t[pos] = '7';
    go(pos + 1, four, seven + 1, 0);
    if (p != "") return;
  }
}
signed main() {
  cin >> s;
  if ((int)s.size() % 2) s = "0" + s;
  int n = (int)s.size();
  t = string(n, '0');
  ;
  go(0, 0, 0, 1);
  ;
  if (p != "") {
    cout << p << '\n';
  } else {
    s = "00" + s;
    ;
    t = string(n + 2, '0');
    go(0, 0, 0, 1);
    cout << p << '\n';
  }
  return 0;
}