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;
int n = 3000;
bool arr[3002];
int ar[3002];
void prime() {
  for (int i = 2; i < n; i += 2) {
    arr[i] = 1;
  }
  arr[2] = 0;
  for (int j = 3; j * j < n; j++) {
    if (!arr[j])
      for (int i = j * j; i < n; i += j) arr[i] = 1;
  }
}
void getall(int x) {
  ar[6] = 1;
  for (int i = 7; i <= x; i++) {
    int cntr = 0;
    for (int j = 2; j <= i / 2; j++) {
      if (!arr[j] && !(i % j)) cntr++;
    }
    if (cntr == 2) {
      ar[i] = ar[i - 1] + 1;
    } else
      ar[i] = ar[i - 1];
  }
}
set<long long> st;
void get(long long s, long long c, int c4, int c7) {
  if (s > 4444477777) return;
  if ((c4 + c7) % 2 == 0 && c4 == c7) st.insert(s);
  if (c4 < 5) get(s + 4 * c, c * 10, c4 + 1, c7);
  if (c7 < 5) get(s + 7 * c, c * 10, c4, c7 + 1);
}
int main() {
  get(0, 1, 0, 0);
  set<long long>::iterator it = st.begin();
  long long x;
  scanf("%lld", &x);
  while (it != st.end() && (*it) < x) {
    it++;
  }
  cout << (*it);
  return 0;
}