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;
using ll = long long;
using vll = vector<ll>;
int solve() {
  string t;
  cin >> t;
  ll a = 0, flag = 1, r = 0, b = 0;
  vector<int> data(t.size());
  if (t.size() % 2 == 1) flag = 0;
  vector<ll> s;
  for (ll j = 0; j < t.size(); j++) {
    if (t[j] - 0 == 52) {
      data[j] = 4;
      a++;
      s.push_back(j);
    } else if (t[j] - 0 == 55) {
      data[j] = 7;
      a--;
    } else if (t[j] - 0 < 52) {
      data[j] = 4;
      r = 1;
      b = j + 1;
      break;
    } else if (t[j] - 0 < 55) {
      data[j] = 7;
      r = 1;
      b = j + 1;
      break;
    } else if (!s.empty()) {
      r = 1;
      b = s[s.size() - 1] + 1;
      a--;
      data[s[s.size() - 1]] = 7;
      break;
    } else
      flag = 0;
  }
  if (r == 1) {
    for (ll qw = b; qw < t.size(); qw++) {
      data[qw] = 4;
    }
    a = 0;
    for (ll qw = 0; qw < t.size(); qw++) {
      if (data[qw] == 4)
        a++;
      else
        a--;
    }
  }
  if (flag == 1) {
    if (a < 0 && s.empty())
      flag = 0;
    else if (a < 0 && !s.empty()) {
      while (a < 0 && !s.empty()) {
        data[s[s.size() - 1]] = 7;
        for (ll qw = s[s.size() - 1] + 1; qw < t.size(); qw++) {
          data[qw] = 4;
        }
        a = 0;
        for (ll qw = 0; qw < t.size(); qw++) {
          if (data[qw] == 4)
            a++;
          else
            a--;
        }
        s.pop_back();
      }
      if (a < 0) flag = 0;
    }
    if (flag == 1) {
      for (ll j = t.size() - 1; j > -1; j--) {
        if (data[j] == 4 && a > 0) {
          data[j] = 7;
          a = a - 2;
        }
      }
      for (ll j = 0; j < t.size(); j++) {
        cout << data[j];
      }
    }
  }
  if (flag == 0) {
    for (ll j = 0; j < 1 + (t.size() / 2); j++) cout << 4;
    for (ll j = 0; j < 1 + (t.size() / 2); j++) cout << 7;
  }
  cout << endl;
  return 0;
}
int main() {
  for (int qwer = 0; qwer < 1; qwer++) {
    solve();
  }
}