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 MOD = 1e9 + 7;
string s;
void answer(string ans) {
  if (ans < s || ans.size() % 2) {
    int n = ((s.size()) / 2) + 1;
    ans = string(n, '4') + string(n, '7');
  }
  cout << ans << '\n';
  exit(0);
}
int main() {
  cin >> s;
  int n = s.size();
  s[n - 1]--;
  for (int i = n - 1; i >= 0; --i)
    if (s[i] < '0') {
      s[i] += 10;
      s[i - 1]--;
    }
  int four_rem = n / 2, seven_rem = n - four_rem;
  string ans;
  int last_kill = -1;
  for (int i = 0; i < n; ++i) {
    if (s[i] < '4' && four_rem > 0) {
      ans += '4';
      --four_rem;
      for (int j = i + 1; j < n; ++j)
        if (four_rem) {
          ans += '4';
          --four_rem;
        } else {
          ans += '7';
          --seven_rem;
        }
      answer(ans);
    }
    if (s[i] < '7' && seven_rem > 0) {
      last_kill = i;
    }
    if (s[i] == '4') {
      if (four_rem == 0) break;
      --four_rem;
      ans += '4';
    } else if (s[i] == '7') {
      if (seven_rem == 0) break;
      --seven_rem;
      ans += '7';
    } else {
      break;
    }
  }
  if (last_kill == -1) answer("");
  while (four_rem-- > 0) ans += '4';
  while (seven_rem-- > 0) ans += '7';
  for (int i = last_kill; i < n; ++i)
    if (ans[i] == '7') {
      swap(ans[i], ans[last_kill]);
      break;
    }
  sort(ans.begin() + last_kill + 1, ans.end());
  answer(ans);
}