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;
int len7, len4, cnt7[1000000], cnt4[1000000];
char second[10000000];
void print() {
  for (int i = 0; i < len4; ++i) putchar('4');
  for (int i = 0; i < len7; ++i) putchar('7');
  exit(0);
}
int main() {
  gets(second);
  int len = strlen(second);
  len7 = (len + 1) / 2;
  len4 = (len + 1) / 2;
  if (len % 2 == 1) print();
  for (int i = len - 1; i >= 0; i--) {
    if (second[i] == '7')
      cnt7[i] = cnt7[i + 1] + 1;
    else
      cnt7[i] = 0;
    if (second[i] == '4')
      cnt4[i] = cnt4[i + 1] + 1;
    else
      cnt4[i] = 0;
  }
  for (int i = 0; i < len; ++i) {
    if (second[i] < '4') {
      for (int j = 0; j < i; ++j) putchar(second[j]);
      print();
    }
    if (second[i] == '4') {
      if (cnt7[i + 1] > len7) {
        for (int j = 0; j < i; ++j) putchar(second[j]);
        putchar('7');
        len7--;
        print();
      } else if (cnt7[i + 1] == len7) {
        int pos = i + 1 + cnt7[i + 1];
        if (second[cnt4[pos] + pos] < '4')
          ;
        else {
          for (int j = 0; j < i; ++j) putchar(second[j]);
          putchar('7');
          len7--;
          print();
        }
      } else if (second[i + 1 + cnt7[i + 1]] < '7')
        ;
      else {
        for (int j = 0; j < i; ++j) putchar(second[j]);
        putchar('7');
        len7--;
        print();
      }
      len4--;
    } else if (second[i] < '7') {
      for (int j = 0; j < i; ++j) putchar(second[j]);
      putchar('7');
      len7--;
      print();
    } else if (second[i] == '7') {
      if (cnt7[i] > len7) {
        len4 = len / 2 + 1;
        len7 = len / 2 + 1;
        print();
      } else if (cnt7[i] == len7) {
        int pos = i + cnt7[i];
        if (second[cnt4[pos] + pos] < '4')
          ;
        else {
          len4 = len / 2 + 1;
          len7 = len / 2 + 1;
          print();
        }
      } else if (second[i + cnt7[i]] < '7')
        ;
      else {
        len4 = len / 2 + 1;
        len7 = len / 2 + 1;
        print();
      }
      len7--;
    } else {
      len4 = len / 2 + 1;
      len7 = len / 2 + 1;
      print();
    }
  }
  puts(second);
  return 0;
}