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 long long INF = 1e9 + 7;
const int N = 2e5 + 10;
void refrain(string &str) {
  if (str.length() % 2 == 1) {
    int o = (str.length() + 1) / 2;
    str = string(o, '4') + string(o, '7');
    return;
  }
  int l = str.length();
  for (int i = 0; i < l; i++) {
    if (str[i] == '4' || str[i] == '7') continue;
    if (str[i] > '7') {
      int c = 1;
      str[i] = '4';
      for (int j = i + 1; j < l; j++) str[i] = '4';
      for (int j = i - 1; j >= 0; j--) {
        if (str[j] >= '7')
          str[j] = '4', c = 1;
        else if (str[j] >= '4')
          str[j] = '7', c = 0;
        else
          str[j] = '4', c = 0;
        if (c == 0) break;
      }
      if (c == 1) {
        l++;
        if (l & 1) l++;
        int o = l / 2;
        str = string(o, '4') + string(o, '7');
        return;
      }
    } else if (str[i] > '4') {
      str[i] = '7';
      for (int j = i + 1; j < l; j++) str[j] = '4';
    } else {
      str[i] = '4';
      for (int j = i + 1; j < l; j++) str[j] = '4';
    }
  }
  int a4 = 0, a7 = 0;
  int key = -1;
  for (int i = 0; i < l; i++) {
    if (str[i] == '4') {
      if (a4 <= l / 2 && a7 + 1 <= l / 2) key = i;
    }
    if (str[i] == '4')
      a4++;
    else
      a7++;
  }
  if (a4 == a7) return;
  if (key == -1) {
    int o = l / 2 + 1;
    str = string(o, '4') + string(o, '7');
    return;
  }
  a4 = a7 = 0;
  for (int i = 0; i < key; i++) {
    if (str[i] == '4')
      a4++;
    else
      a7++;
  }
  str[key++] = '7';
  a7++;
  while (a4++ < l / 2) str[key++] = '4';
  while (a7++ < l / 2) str[key++] = '7';
}
int main() {
  string str;
  cin >> str;
  refrain(str);
  cout << str << endl;
  return 0;
}