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 str[100005];
int flag[100005];
void print(int len) {
  for (int i = 0; i < len / 2; i++) {
    printf("4");
  }
  for (int j = len / 2; j < len; j++) {
    printf("7");
  }
  printf("\n");
}
int main() {
  scanf("%s", str);
  int len = strlen(str);
  memset(flag, 0, sizeof(flag));
  if (len % 2) {
    print(len + 1);
  } else {
    if ((str[0] - '0') > 7) {
      print(len + 2);
    } else {
      int cnt = 0, x = 0, y = 0;
      for (int i = len - 1; i >= 0; i--) {
        if ((str[i] - '0' + cnt) > 7) {
          if (i == 0) {
            print(len + 2);
            return 0;
          }
          cnt = 1;
          str[i] = '4';
        } else if ((str[i] - '0' + cnt) > 4 && (str[i] - '0' + cnt) < 7) {
          cnt = 0;
          str[i] = '7';
          flag[i + 1] = 1;
        } else if ((str[i] - '0' + cnt) < 4) {
          cnt = 0;
          str[i] = '4';
          flag[i + 1] = 1;
        } else if ((str[i] - '0' + cnt) == 4) {
          str[i] = '4';
          if (cnt) {
            flag[i + 1] = 1;
          }
          cnt = 0;
        } else {
          str[i] = '7';
          if (cnt) {
            flag[i + 1] = 1;
          }
          cnt = 0;
        }
      }
      int pos = -1;
      for (int i = 0; i < len; i++) {
        if (flag[i]) {
          pos = i;
          break;
        }
      }
      if (pos != -1)
        for (int i = pos; i < len; i++) {
          str[i] = '4';
        }
      for (int i = 0; i < len; i++) {
        if (str[i] == '4')
          x++;
        else
          y++;
      }
      if (x == y)
        printf("%s\n", str);
      else if (x > y) {
        int ans = x - y, flag = 0;
        for (int i = len - 1; i >= 0; i--) {
          if (ans == 0) {
            printf("%s\n", str);
            break;
          } else {
            if (str[i] == '4') {
              str[i] = '7';
              ans -= 2;
            }
          }
        }
      } else {
        int ans = y - x;
        for (int i = len - 1; i >= 0; i--) {
          int p = 0;
          if ((str[i] - '0') == 4) {
            for (int j = 0; j < i; j++) {
              if (str[j] == '4') p++;
            }
            if (((len - 1 - i) + p) >= len / 2) {
              str[i] = '7';
              ans += 2;
              for (int j = i + 1; j < len; j++) {
                if (ans == 0) {
                  printf("%s\n", str);
                  return 0;
                }
                if (str[j] == '7') {
                  str[j] = '4';
                  ans -= 2;
                }
              }
              printf("%s\n", str);
              return 0;
            }
          }
        }
        print(len + 2);
      }
    }
  }
}