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;
string a;
string ans = "", x = "";
bool Judge() {
  if (a.size() % 2) {
    return false;
  }
  string temp = "";
  for (int i = 0; i < a.size(); i++) {
    if (i < a.size() / 2) {
      temp += "7";
    } else {
      temp += "4";
    }
  }
  return temp >= a;
}
void Deal() {
  int t = a.size();
  t = t % 2 ? t + 1 : t + 2;
  for (int i = 0; i < t; i++) {
    if (i < t / 2) {
      ans += "4";
    } else {
      ans += "7";
    }
  }
  return;
}
void Dfs(int num4, int num7, int pos, bool flag) {
  if (ans != "") {
    return;
  }
  if (x < a.substr(0, x.size())) {
    return;
  }
  if (num4 > a.size() / 2 || num7 > a.size() / 2) {
    return;
  }
  if (x.size() == a.size()) {
    if (num4 == num7 && x >= a) {
      if (x < ans || ans == "") {
        ans = x;
        return;
      }
    }
  }
  if (flag == true) {
    ans = x;
    while (num4 < a.size() / 2) {
      ans += '4';
      num4++;
    }
    while (num7 < a.size() / 2) {
      ans += '7';
      num7++;
    }
    return;
  }
  if (a[pos] <= '4') {
    x += "4";
    Dfs(num4 + 1, num7, pos + 1, (a[pos] != '4'));
    x.erase(x.size() - 1, 1);
  }
  if (a[pos] <= '7') {
    x += "7";
    Dfs(num4, num7 + 1, pos + 1, (a[pos] != '7'));
    x.erase(x.size() - 1, 1);
  }
  return;
}
int main() {
  cin >> a;
  if (Judge()) {
    Dfs(0, 0, 0, false);
  } else {
    Deal();
  }
  cout << ans << endl;
  return 0;
}