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 OO = (int)2e9;
const double eps = 1e-9;
int main() {
  std::ios_base::sync_with_stdio(false);
  string str;
  cin >> str;
  int i, n = ((int)(str).size()), k = (n + 1) / 2, a4 = 0, a7 = 0, rem = 0;
  string tmp = string(k, '7') + string(k, '4');
  if ((n & 1) || (2 * k == n && tmp < str)) {
    if (!(n & 1)) k++;
    tmp = string(k, '4') + string(k, '7');
    cout << tmp << endl;
    return 0;
  }
  tmp = str;
  int maxIdx = n;
  for ((i) = (n - 1); (i) >= 0; (i)--) {
    if (rem) {
      rem = 0;
      if (str[i] == '4')
        str[i] = '7';
      else if (str[i] == '7')
        str[i] = '4', rem = 1;
    }
    if (str[i] != '4' && str[i] != '7') maxIdx = i + 1;
    if (str[i] <= '4')
      a4++, str[i] = '4';
    else if (str[i] <= '7')
      a7++, str[i] = '7';
    else
      rem++, a4++, str[i] = '4';
  }
  sort(str.begin() + maxIdx, str.end());
  if (a7 < a4) {
    for ((i) = (n - 1); (i) >= 0; (i)--) {
      if (str[i] == '4') str[i] = '7', a7++, a4--;
      if (a4 == a7) break;
    }
  } else if (a4 < a7) {
    for ((i) = (n - 1); (i) >= 0; (i)--) {
      if (str[i] == '7') str[i] = '4', a7--, a4++;
      if (a4 == a7) {
        bool flag = 1;
        for (int j = i - 1; j >= 0; j--) {
          if (str[j] == '7' && flag)
            str[j] = '4', flag = 0;
          else if (str[j] == '4' && !flag) {
            str[j] = '7';
            sort(str.begin() + j + 1, str.end());
            break;
          }
        }
        break;
      }
    }
  }
  cout << str << endl;
  return 0;
}