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;
bool cmp(long long a, long long b) { return (a > b); }
long long ceil(const long long &a, const long long &b) {
  if (a % b == 0) return a / b;
  return a / b + 1;
}
long long mod = 1000000007;
const long long N = 200005;
long long go(string s) {
  stringstream geek(s);
  long long x = 0;
  geek >> x;
  return x;
}
long long n;
string s;
char res1[N];
void solve(long long i, long long f, long long x, long long y) {
  if (i >= n) {
    cout << res1;
    exit(0);
  }
  if ((s[i] - '0') < 4) {
    if (x) {
      res1[i] = '4';
      solve(i + 1, 1, x - 1, y);
    }
    if (y) {
      res1[i] = '7';
      solve(i + 1, 1, x, y - 1);
    }
  } else if ((s[i] - '0') == 4) {
    if (x) {
      res1[i] = '4';
      solve(i + 1, f, x - 1, y);
    }
    if (y) {
      res1[i] = '7';
      solve(i + 1, 1, x, y - 1);
    }
  } else if ((s[i] - '0') < 7) {
    if (f && x) {
      res1[i] = '4';
      solve(i + 1, 1, x - 1, y);
    }
    if (y) {
      res1[i] = '7';
      solve(i + 1, 1, x, y - 1);
    }
  } else if ((s[i] - '0') == 7) {
    if (f && x) {
      res1[i] = '4';
      solve(i + 1, 1, x - 1, y);
    }
    if (y) {
      res1[i] = '7';
      solve(i + 1, f, x, y - 1);
    }
  } else {
    if (f && x) {
      res1[i] = '4';
      solve(i + 1, 1, x - 1, y);
    }
    if (f && y) {
      res1[i] = '7';
      solve(i + 1, 1, x, y - 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  string res = "";
  n = s.size();
  long long flag = 1;
  if (n % 2 == 0) {
    long long x = n / 2;
    long long y = n / 2;
    long long f = 0;
    solve(0, 0, x, y);
  }
  if (n % 2 == 0) {
    n++;
  }
  if (n % 2) {
    res = "";
    for (long long i = 0; i < n / 2 + 1; i++) {
      res += '4';
    }
    for (long long i = 0; i < n / 2 + 1; i++) {
      res += '7';
    }
    cout << res;
  }
  return 0;
}