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 second;
string smallest(int n) {
  string res;
  for (int i = 0; i < n; i++) res += '4';
  for (int i = 0; i < n; i++) res += '7';
  return res;
}
string largest(int n) {
  string res;
  for (int i = 0; i < n; i++) res += '7';
  for (int i = 0; i < n; i++) res += '4';
  return res;
}
bool go(int n4, int n7, string &res, bool won = false) {
  if (!n4 && !n7) {
    if (res >= second) return true;
    return false;
  }
  if (won) {
    if (n4) {
      res += '4';
      assert(go(n4 - 1, n7, res, true));
    } else {
      res += '7';
      assert(go(n4, n7 - 1, res, true));
    }
    return true;
  }
  if (!n4) {
    res += '7';
    if (go(n4, n7 - 1, res)) return true;
    res.pop_back();
    return false;
  }
  if (!n7) {
    res += '4';
    if (go(n4 - 1, n7, res)) return true;
    res.pop_back();
    return false;
  }
  char c = second[((int)(second).size()) - n4 - n7];
  if (c < '4') {
    res += '4';
    assert(go(n4 - 1, n7, res, true));
    return true;
  } else if (c == '4') {
    res += '4';
    if (go(n4 - 1, n7, res)) return true;
    res.back() = '7';
    assert(go(n4, n7 - 1, res, true));
    return true;
  } else if (c < '7') {
    res += '7';
    assert(go(n4, n7 - 1, res, true));
    return true;
  } else if (c == '7') {
    res += '7';
    if (go(n4, n7 - 1, res)) return true;
    res.pop_back();
    return false;
  } else
    return false;
}
int main() {
  cin >> second;
  if (((int)(second).size()) % 2 == 1)
    cout << smallest(((int)(second).size()) / 2 + 1) << endl;
  else {
    string &&tmp = largest(((int)(second).size()) / 2);
    if (tmp >= second) {
      string ans;
      assert(go(((int)(second).size()) / 2, ((int)(second).size()) / 2, ans));
      cout << ans << endl;
    } else
      cout << smallest(((int)(second).size()) / 2 + 1) << endl;
  }
  return 0;
}