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 ans, s;
long long int ok, l;
void fill(long long int pos, long long int ctr4, long long int ctr7) {
  for (long long int i = 0; i < ctr4; i++) ans[pos + i] = '4';
  for (long long int i = 0; i < ctr7; i++) ans[pos + i + ctr4] = '7';
  ok = 1;
}
void solve(long long int pos, long long int ctr4, long long int ctr7) {
  if (pos == l) {
    ok = 1;
    return;
  }
  long long int cur = s[pos] - '0';
  if (cur < 4) {
    fill(pos, ctr4, ctr7);
    return;
  }
  if (cur == 4 && ctr4) {
    ans[pos] = '4';
    solve(pos + 1, ctr4 - 1, ctr7);
    if (ok) return;
  }
  if (cur < 7 && ctr7) {
    ans[pos] = '7';
    fill(pos + 1, ctr4, ctr7 - 1);
    return;
  }
  if (cur == 7 && ctr7) {
    ans[pos] = '7';
    solve(pos + 1, ctr4, ctr7 - 1);
  }
}
int main() {
  long long int i, j;
  cin >> s;
  ans = s;
  l = s.length();
  ok = 0;
  if (l % 2 == 0) solve(0, l / 2, l / 2);
  if (!ok) {
    l++;
    for (i = 0; i < (l + 1) / 2; i++) cout << "4";
    for (i = 0; i < (l + 1) / 2; i++) cout << "7";
    return 0;
  }
  cout << ans;
  return 0;
}