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;
void print(char* t, int k) {
  for (int i = 0; i < k; i++) t[i] = '4';
  for (int i = 0; i < k; i++) t[i + k] = '7';
  t[k + k] = 0;
}
void go2(char* s, int idx) {
  int n = strlen(s);
  int k = n / 2;
  int se = 0;
  int fo = 0;
  for (int i = 0; i < idx; i++) {
    if (s[i] == '4')
      fo++;
    else
      se++;
  }
  for (int i = idx; i < n; i++) {
    if (fo < k) {
      s[i] = '4';
      fo++;
    } else {
      s[i] = '7';
      se++;
    }
  }
}
bool go(char* s) {
  int n = strlen(s);
  int se = 0;
  int fo = 0;
  if (n % 2 == 1) {
    int k = n / 2 + 1;
    print(s, k);
    return true;
  }
  int k = n / 2;
  for (int i = 0; i < n; i++) {
    if (s[i] > '7') {
      if (i == 0) {
        print(s, k + 1);
        return true;
      }
      s[i - 1]++;
      s[i] = '0';
      return false;
    } else if (s[i] == '7') {
      if (se < k) {
        se++;
      } else {
        s[i - 1]++;
        s[i] = '0';
        return false;
      }
    } else if (s[i] > '4') {
      if (se < k) {
        s[i] = '7';
        go2(s, i + 1);
        return true;
      } else {
        s[i - 1]++;
        s[i] = '0';
        return false;
      }
    } else if (s[i] == '4') {
      if (fo < k) {
        fo++;
      } else {
        s[i] = '7';
        go2(s, i + 1);
        return true;
      }
    } else {
      if (fo < k) {
        s[i] = '4';
        go2(s, i + 1);
        return true;
      } else {
        s[i] = '7';
        go2(s, i + 1);
        return true;
      }
    }
  }
  return true;
}
void calc(char* s) {
  while (!go(s))
    ;
}
bool test(long long m) {
  while (m > 0) {
    if (m % 10 == 4 || m % 10 == 7) {
      m /= 10;
    } else {
      return false;
    }
  }
  return true;
}
int main() {
  char s[100010];
  cin >> s;
  calc(s);
  cout << s << endl;
  return 0;
}