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 build(int x, int y) {
  string ans;
  for (int n_ = (x), i = 0; i < n_; ++i) ans += '4';
  for (int n_ = (y), i = 0; i < n_; ++i) ans += '7';
  return ans;
}
string solve(string number) {
  string ans;
  if (((int)(number).size()) % 2 == 1) {
    int sz = ((int)(number).size()) + 1;
    return build(sz / 2, sz / 2);
  } else {
    int cnt4 = count((number).begin(), (number).end(), '4');
    int cnt7 = count((number).begin(), (number).end(), '7');
    if (cnt4 == cnt7 && cnt4 + cnt7 == ((int)(number).size())) {
      return number;
    }
    int should_change = ((int)(number).size()) - 1;
    for (int n_ = (((int)(number).size())), i = 0; i < n_; ++i) {
      if (number[i] != '4' && number[i] != '7') {
        should_change = i;
        break;
      }
    }
    cnt4 = cnt7 = 0;
    for (int n_ = (should_change + 1), i = 0; i < n_; ++i) {
      if (number[i] == '4') cnt4++;
      if (number[i] == '7') cnt7++;
    }
    int sz = number.size() / 2;
    for (int i = should_change; i >= 0; --i) {
      if (number[i] == '4') cnt4--;
      if (number[i] == '7') cnt7--;
      if ('4' > number[i]) {
        if (cnt4 + 1 <= sz && cnt7 <= sz) {
          return number.substr(0, i) + "4" + build(sz - cnt4 - 1, sz - cnt7);
        }
      }
      if ('7' > number[i]) {
        if (cnt4 <= sz && cnt7 + 1 <= sz) {
          return number.substr(0, i) + "7" + build(sz - cnt4, sz - cnt7 - 1);
        }
      }
    }
    int n = sz * 2 + 2;
    return build(n / 2, n / 2);
  }
}
int main() {
  string number;
  while (cin >> number) {
    cout << solve(number) << endl;
  }
  return 0;
}