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 n, k, d;
bool check(long long x) {
  string y = to_string(x);
  long long z = 0, z1 = 0;
  for (long long i = 0; i < y.size(); i++) {
    if (y[i] != '4' && y[i] != '7')
      return false;
    else if (y[i] == '4')
      z++;
    else
      z1++;
  }
  if (z == z1) return true;
  return false;
}
int32_t main() {
  cin >> n;
  vector<long long> V;
  V.push_back(47);
  V.push_back(74);
  V.push_back(4477);
  V.push_back(4747);
  V.push_back(4774);
  V.push_back(7474);
  V.push_back(7447);
  V.push_back(7744);
  string s = "777777";
  for (long long i = 0; i < 4; i++) {
    for (long long j = (i + 1); j < 5; j++) {
      for (long long k = (j + 1); k < 6; k++) {
        s[i] = '4';
        s[j] = '4';
        s[k] = '4';
        long long z = stoi(s);
        s[i] = '7';
        s[j] = '7';
        s[k] = '7';
        V.push_back(z);
      }
    }
  }
  s = "77777777";
  for (long long i = 0; i < 5; i++) {
    for (long long j = (i + 1); j < 6; j++) {
      for (long long k = (j + 1); k < 7; k++) {
        for (long long l = (k + 1); l < 8; l++) {
          s[i] = '4';
          s[j] = '4';
          s[k] = '4';
          s[l] = '4';
          long long z = stoi(s);
          s[i] = '7';
          s[j] = '7';
          s[k] = '7';
          s[l] = '7';
          V.push_back(z);
        }
      }
    }
  }
  V.push_back(4444477777);
  sort(V.begin(), V.end());
  long long st = 0;
  long long end = V.size() - 1;
  long long z = lower_bound(V.begin(), V.end(), n) - V.begin();
  cout << V[z] << "\n";
  for (long long i = 0; i < V.size(); i++) return 0;
}