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;
const int INF = 1 << 27;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;
string ans;
string number;
int n;
void solve(int cnt, int f, int s, bool ok) {
  if (cnt == 0) {
    for (int i = 0; i < n; i++) cout << ans[i];
    cout << endl;
    exit(0);
  }
  if (f > 0 && (number[n - cnt] <= '4' || ok)) {
    ans[n - cnt] = '4';
    solve(cnt - 1, f - 1, s, ok || (number[n - cnt] < '4'));
  }
  if (s > 0 && (number[n - cnt] <= '7' || ok)) {
    ans[n - cnt] = '7';
    solve(cnt - 1, f, s - 1, ok || (number[n - cnt] < '7'));
  }
}
void doit(int l) {
  if (l % 2 == 1) return;
  if (l > n) {
    for (int i = 0; i < l / 2; i++) cout << 4;
    for (int i = 0; i < l / 2; i++) cout << 7;
    cout << endl;
    exit(0);
  }
  solve(n, n / 2, n / 2, false);
}
int main() {
  cin >> number;
  n = number.size();
  ans = string(n + 2, ' ');
  doit(n);
  doit(n + 1);
  doit(n + 2);
  return 0;
}