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 N = 100005;
int len;
char s[N], ans[N];
void print(int k) {
  for (int i = 1; i <= k / 2; i++) cout << '4';
  for (int i = 1; i <= k / 2; i++) cout << '7';
}
bool search(int k, int c4, int c7, int f) {
  if (k == len) return 1;
  if (f) {
    for (int i = 0; i + k < len; i++) {
      if (i < len / 2 - c4)
        ans[i + k] = '4';
      else
        ans[i + k] = '7';
    }
    return 1;
  }
  if (c4 < len / 2 && s[k] <= '4') {
    if (search(k + 1, c4 + 1, c7, s[k] < '4')) {
      ans[k] = '4';
      return 1;
    }
  }
  if (c7 < len / 2 && s[k] <= '7') {
    if (search(k + 1, c4, c7 + 1, s[k] < '7')) {
      ans[k] = '7';
      return 1;
    }
  }
  return 0;
}
int main() {
  scanf("%s", s);
  len = strlen(s);
  if (len & 1)
    print(len + 1);
  else {
    if (search(0, 0, 0, 0))
      printf("%s", ans);
    else
      print(len + 2);
  }
  return 0;
}