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;
vector<char> s, ans;
ostream& operator<<(ostream& out, vector<char>& t) {
  for (int i = 0; i < t.size(); i++) printf("%c", t[i]);
  return out;
}
void genSuff(int ind, int fr, int sv, vector<char>& a) {
  while (a.size() > ind) a.pop_back();
  for (int i = 0; i < fr; i++) a.push_back('4');
  for (int i = 0; i < sv; i++) a.push_back('7');
}
void tryGen(vector<char> s) {
  if (s.size() & 1) return;
  int mini = -1, kfr, ksv, n = s.size(), fr = n / 2, sv = n / 2;
  for (int i = 0; i < n && ans.size() < n; i++)
    if (s[i] < '4') {
      ans.push_back(fr != 0 ? '4' : '7');
      genSuff(i + 1, fr - (fr > 0), sv - (fr == 0), ans);
    } else if (s[i] == '4' && fr > 0) {
      ans.push_back('4');
      fr--;
      if (sv != 0) {
        mini = i;
        kfr = fr;
        ksv = sv;
      }
    } else if (s[i] == '4') {
      ans.push_back('7');
      genSuff(i + 1, fr, sv - 1, ans);
    } else if (s[i] <= '7' && sv > 0) {
      ans.push_back('7');
      sv--;
      if (s[i] < '7') genSuff(i + 1, fr, sv, ans);
    } else {
      if (mini == -1) {
        ans.clear();
        return;
      }
      ans[mini] = '7';
      ksv--;
      kfr++;
      genSuff(mini + 1, kfr, ksv, ans);
    }
}
int main() {
  char r;
  while (cin >> r) s.push_back(r);
  tryGen(s);
  if (ans.size() == 0) genSuff(0, (s.size() + 2) / 2, (s.size() + 2) / 2, ans);
  cout << ans;
  return 0;
}