Problem: A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.

The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.

Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.

If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.

Input

The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).

Output

Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.

Examples

Input

1033


Output

33


Input

10


Output

0


Input

11


Output

-1

Note

In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cout << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cout.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
using namespace std;
long long int to_ll(string& s) {
  long long int i, ret = 0, p = 1;
  for (i = (long long int)s.length() - 1; i >= 0; i--)
    ret += (s[i] - '0') * p, p *= 10LL;
  return ret;
}
long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long int pwr(long long int base, long long int expo, long long int m) {
  if (base == 0) return 0LL;
  if (expo == 0) return (1LL % m);
  if ((expo & 1) == 0) {
    long long int temp = pwr(base, expo >> 1, m);
    return (temp * temp) % m;
  }
  return ((base % m) * pwr(base, expo - 1, m)) % 1000000007;
}
string s;
vector<long long int> v;
long long int dp[100009][3], pref[100009][3];
long long int get_y(long long int x, long long int dig) {
  long long int i;
  for (i = 0; i < 3; i++) {
    if ((dig + i) % 3 == x) return i;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int i, j, n, idx = -1;
  cin >> s;
  n = s.length();
  for (i = 0; i < n; i++) v.push_back((s[i] - '0') % 3);
  dp[n - 1][v[n - 1]] = 1;
  pref[n - 1][v[n - 1]] = 1;
  for (i = n - 2; i >= 0; i--) {
    for (j = 0; j < 3; j++) {
      long long int x = j;
      long long int y = get_y(x, v[i]);
      if (pref[i + 1][y] == 0) {
        if (v[i] == x)
          dp[i][x] = 1;
        else
          dp[i][x] = 0;
      } else
        dp[i][x] = 1 + pref[i + 1][y];
    }
    pref[i][0] = max(dp[i][0], pref[i + 1][0]);
    pref[i][1] = max(dp[i][1], pref[i + 1][1]);
    pref[i][2] = max(dp[i][2], pref[i + 1][2]);
  }
  long long int mx = -1000000000000000007LL;
  long long int zero = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == '0') {
      zero++;
      continue;
    }
    if (mx < dp[i][0]) {
      mx = dp[i][0];
      idx = i;
    }
  }
  if (mx == 0) {
    if (zero > 0)
      cout << "0\n";
    else
      cout << "-1\n";
    return 0;
  }
  long long int x = 0, y = 0, cnt = mx;
  while (cnt--) {
    cout << s[idx];
    y = get_y(x, v[idx]);
    for (i = idx + 1; i < n; i++) {
      if (dp[i][y] + 1 == dp[idx][x]) {
        idx = i;
        x = y;
        break;
      }
    }
  }
  return 0;
}