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;
string get(int n, int m) {
  string str;
  for (int i = 1; i <= n; i++) str.push_back('4');
  for (int i = 1; i <= m; i++) str.push_back('7');
  return str;
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  string str;
  cin >> str;
  int n = str.size();
  if (n & 1) {
    cout << get((n + 1) / 2, (n + 1) / 2) << endl;
    return 0;
  }
  int cnta = 0, cntb = 0, ans = -1, aa = 0, bb = 0;
  for (int i = 0; i < n; i++) {
    if (cnta + 1 <= n / 2 && str[i] < '7') {
      ans = i;
      aa = cnta;
      bb = cntb;
    }
    if (cntb + 1 <= n / 2 && str[i] < '4') {
      ans = i;
      aa = cnta;
      bb = cntb;
    }
    cnta += str[i] == '7';
    cntb += str[i] == '4';
    if ((str[i] != '4' && str[i] != '7') || cnta > n / 2 || cntb > n / 2) break;
  }
  if (cnta + cntb == n && cnta == cntb) {
    cout << str << endl;
    return 0;
  }
  if (ans == -1) {
    cout << get((n + 2) / 2, (n + 2) / 2) << endl;
    return 0;
  }
  string x;
  for (int i = 0; i < ans; i++) {
    x.push_back(str[i]);
  }
  if (bb + 1 <= n / 2 && str[ans] < '4') {
    ++bb;
    x.push_back('4');
  } else {
    ++aa;
    x.push_back('7');
  }
  x += get(n / 2 - bb, n / 2 - aa);
  cout << x << endl;
}