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;
string s;
char res[100010];
int len;
int func(int cur, int n4, int n7, int prev) {
  if (cur == len) {
    for (int i = (0), _n = (len); i < _n; i++) printf("%c", res[i]);
    cout << endl;
    return 1;
  } else {
    if (prev) {
      if (n4) {
        res[cur] = '4';
        return func(cur + 1, n4 - 1, n7, 1);
      }
      res[cur] = '7';
      return func(cur + 1, n4, n7 - 1, 1);
    } else {
      if (s[cur] <= '4' && n4) {
        res[cur] = '4';
        int flag = 0;
        if (s[cur] < '4') flag = 1;
        int val = func(cur + 1, n4 - 1, n7, flag);
        if (val) return 1;
      }
      if (s[cur] <= '7' && n7) {
        res[cur] = '7';
        int flag = 0;
        if (s[cur] < '7') flag = 1;
        int val = func(cur + 1, n4, n7 - 1, flag);
        if (val) return 1;
      }
    }
  }
  return 0;
}
int main() {
  cin >> s;
  len = s.size();
  if (len % 2 == 1) {
    len++;
    for (int i = (0), _n = (len / 2); i < _n; i++) printf("4");
    for (int i = (0), _n = (len / 2); i < _n; i++) printf("7");
    cout << endl;
    return 0;
  } else {
    int n4 = len / 2;
    int n7 = len / 2;
    int val = func(0, n4, n7, 0);
    if (!val) {
      len += 2;
      for (int i = (0), _n = (len / 2); i < _n; i++) printf("4");
      for (int i = (0), _n = (len / 2); i < _n; i++) printf("7");
      cout << endl;
      return 0;
    }
  }
  return 0;
}