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 ml = 100005;
string n;
int len, len2;
bool go1() {
  for (int i = 0; i < len2; i++) {
    if (n[i] < '7') return 1;
    if (n[i] > '7') return 0;
  }
  for (int i = len2; i < len; i++) {
    if (n[i] < '4') return 1;
    if (n[i] > '4') return 0;
  }
  return 1;
}
int main() {
  cin >> n;
  len = n.size();
  if (len & 1) {
    n = "1";
    for (int i = 0; i < len; i++) n.push_back('0');
    len++;
  }
  len2 = len / 2;
  if (!go1()) {
    len += 2;
    len2 += 1;
    n = "1";
    for (int i = 0; i < len - 1; i++) n.push_back('0');
  }
  int rem4 = len2, rem7 = len2;
  bool lesser = 0;
  string ans;
  for (int i = 0; i < len; i++) ans.push_back('7');
  for (int i = 0; i < len; i++) {
    if (lesser) {
      if (rem4)
        ans[i] = '4', rem4--;
      else
        ans[i] = '7', rem7--;
    } else {
      if (n[i] <= '4' && rem4) {
        ans[i] = '4', rem4--;
        if (n[i] < '4') lesser = 1;
      } else if (n[i] <= '7' && rem7) {
        ans[i] = '7', rem7--;
        if (n[i] < '7') lesser = 1;
      } else {
        int j;
        for (j = i - 1; j >= 0; j--) {
          if (ans[j] != '4')
            rem7++;
          else {
            if (rem7 > 0)
              break;
            else
              rem4++;
          }
        }
        ans[j] = '7';
        lesser = 1;
        rem4++;
        rem7--;
        i = j;
      }
    }
  }
  cout << ans << endl;
  return 0;
}