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;
char s[100005];
int n;
int main() {
  while (~scanf("%s", s)) {
    n = strlen(s);
    if (n & 1) {
      n = (n + 1) / 2;
      for (int i = 0; i < n; i++) putchar('4');
      for (int i = 0; i < n; i++) putchar('7');
      puts("");
      continue;
    }
    int c4 = 0, c7 = 0, big = 0, can = 1;
    for (int i = 0; i < n; i++) {
      if (big) {
        while (i < n) {
          c4++;
          s[i] = '4';
          i++;
        }
        break;
      }
      if (s[i] < '4') {
        s[i] = '4';
        c4++;
        big = 1;
      } else if (s[i] == '4')
        c4++;
      else if (s[i] < '7') {
        s[i] = '7';
        c7++;
        big = 1;
      } else if (s[i] == '7')
        c7++;
      else if (s[i] > '7') {
        if (c7 == i) {
          can = 0;
          break;
        }
        int j = i - 1;
        while (s[j] == '7') {
          c7--;
          j--;
        }
        s[j] = '7';
        c4--;
        c7++;
        j++;
        big = 1;
        while (j < n) {
          c4++;
          s[j] = '4';
          j++;
        }
        break;
      }
    }
    if (!can || c4 == 0) {
      n = (n + 2) / 2;
      for (int i = 0; i < n; i++) putchar('4');
      for (int i = 0; i < n; i++) putchar('7');
      puts("");
      continue;
    }
    if (c7 > c4) {
      c7++;
      c4--;
      int j = n - 1;
      for (; j >= 0; j--) {
        if (c7 == c4) break;
        if (s[j] == '7') {
          c7--;
          c4++;
          s[j] = '4';
        }
        s[j] = '4';
      }
      if (j < 0)
        can = 0;
      else {
        while (j >= 0 && s[j] == '7') --j;
        if (j < 0)
          can = 0;
        else {
          s[j] = '7';
          sort(s + j + 1, s + n);
        }
      }
    }
    if (!can) {
      n = (n + 2) / 2;
      for (int i = 0; i < n; i++) putchar('4');
      for (int i = 0; i < n; i++) putchar('7');
      puts("");
      continue;
    }
    int dt = (c4 - c7) / 2;
    for (int i = n - 1; i >= 0; i--) {
      if (dt == 0) break;
      if (s[i] == '4') {
        s[i] = '7';
        dt--;
      }
    }
    puts(s);
  }
}