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;
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
long long mod = 1000000007;
string s;
int n;
map<int, int> f;
int calc(int i, char ans[]) {
  if (i == n) return f[4] == f[7];
  for (auto it : f) {
    int x = s[i] - '0';
    if (it.second > 0 and it.first >= x) {
      f[it.first]--;
      ans[i] = (it.first + '0');
      if (it.first > x) {
        int y = (n - i - 1 - abs(f[7] - f[4]));
        if (y % 2 == 0) {
          string s1;
          if (f[4] > f[7])
            s1 = string((f[4] - f[7] + y / 2), '4') + string(y / 2, '7');
          else
            s1 = string(y / 2, '4') + string((f[7] - f[4] + y / 2), '7');
          int k = 0;
          for (int j = i + 1; j < n; j++) {
            ans[j] = s1[k];
            k++;
          }
          return 1;
        }
      }
      if (calc(i + 1, ans)) return 1;
      f[it.first]++;
    }
  }
  return 0;
}
bool test = 0;
void solve() {
  cin >> s;
  n = s.size();
  if (n & 1) {
    int x = (n + 1) / 2;
    cout << string(x, '4') + string(x, '7');
    return;
  }
  f[4] = n / 2;
  f[7] = n / 2;
  char ans[n];
  if (calc(0, ans)) {
    for (int i = 0; i < n; i++) cout << ans[i];
  } else
    cout << string(n / 2 + 1, '4') + string(n / 2 + 1, '7');
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  if (test) cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}