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 int N = 100024;
char ch[N];
int ans[N], c[10], newwpos;
bool found;
bool check(int Nn) {
  for (int i = 1; i <= Nn; i++) {
    int nownum = ch[i] - '0', nowmost = i <= Nn / 2 ? 7 : 4;
    if (nownum == nowmost)
      continue;
    else if (nownum > nowmost)
      return false;
    else
      return true;
  }
  return true;
}
int main() {
  scanf("%s", ch + 1);
  int n = strlen(ch + 1);
  if (n % 2 == 1 || !check(n)) {
    n += n % 2 ? 1 : 2;
    for (int i = 1; i <= n; i++) cout << (i <= n / 2 ? 4 : 7);
    return 0;
  }
  int bef = -1, newwpos = n;
  for (int i = 1; i <= n; i++) {
    int nownum = ch[i] - '0';
    if (nownum == 7 || nownum == 4)
      c[ans[i] = nownum]++, bef = (ans[i] == 4 && !found ? i : bef);
    else if (nownum < 7 && nownum != 4)
      ans[i] = nownum < 4 ? 4 : 7, c[ans[i]]++, newwpos = i,
      bef = (ans[i] == 4 && found ? i : bef);
    if (c[4] > n / 2)
      newwpos = i, ans[newwpos] = 7;
    else if (c[7] == n / 2)
      found = 1;
    else if (c[7] > n / 2 || nownum > 7)
      newwpos = bef, ans[newwpos] = 7;
    if (newwpos != n) break;
  }
  c[4] = 0, c[7] = 0;
  for (int i = 1; i <= newwpos; i++) {
    cout << ans[i];
    c[ans[i]]++;
  }
  for (int i = 1; i <= (n / 2) - c[4]; i++) cout << 4;
  for (int i = 1; i <= (n / 2) - c[7]; i++) cout << 7;
  return 0;
}