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>
using namespace std;
long long MOD_EXPO(long long b, long long p, long long m) {
  if (p == 0) return 1;
  long long ret = MOD_EXPO(b, p / 2, m) % m;
  ret = (ret * ret) % m;
  return ((p & 1) ? (ret * b) % m : ret % m);
}
long long POWER(long long N, long long K) {
  long long i, ans = 1;
  for (i = 1; i <= K; i++) ans *= N;
  return ans;
}
int SET(int N, int pos) { return (N | (1 << pos)); }
int RESET(int N, int pos) { return (N & !(1 << pos)); }
bool CHECK(int N, int pos) { return (N & (1 << pos)); }
int dx4[] = {1, -1, 0, 0};
int dy4[] = {0, 0, 1, -1};
int dx6[] = {0, 0, 1, -1, 0, 0};
int dy6[] = {1, -1, 0, 0, 0, 0};
int dz6[] = {0, 0, 0, 0, 1, -1};
int dx8[] = {1, -1, 0, 0, -1, 1, -1, 1};
int dy8[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dkx8[] = {-1, 1, -1, 1, -2, -2, 2, 2};
int dky8[] = {2, 2, -2, -2, 1, -1, 1, -1};
int tc = 1;
const double eps = 1e-9;
const double pi = acos(-1.0);
const long long int mx = 1e5;
const long long int mod = 1e9 + 7;
vector<pair<int, int> > mod1, mod2;
string output;
void init(void) {
  mod1.push_back(pair<int, int>(1, -1));
  mod1.push_back(pair<int, int>(4, -1));
  mod1.push_back(pair<int, int>(2, 2));
  mod1.push_back(pair<int, int>(7, -1));
  mod1.push_back(pair<int, int>(2, 5));
  mod1.push_back(pair<int, int>(2, 8));
  mod1.push_back(pair<int, int>(5, 5));
  mod1.push_back(pair<int, int>(5, 8));
  mod1.push_back(pair<int, int>(8, 8));
  mod2.push_back(pair<int, int>(2, -1));
  mod2.push_back(pair<int, int>(1, 1));
  mod2.push_back(pair<int, int>(5, -1));
  mod2.push_back(pair<int, int>(1, 4));
  mod2.push_back(pair<int, int>(8, -1));
  mod2.push_back(pair<int, int>(1, 7));
  mod2.push_back(pair<int, int>(4, 4));
  mod2.push_back(pair<int, int>(4, 7));
  mod2.push_back(pair<int, int>(7, 7));
}
string make_beautiful(string str, pair<int, int> p) {
  int i, a, b, c, cnt, need, sum;
  cnt = 0;
  a = p.first;
  b = p.second;
  need = (a > 0) + (b > 0);
  for (i = str.size() - 1; i >= 0; i--) {
    c = str[i] - '0';
    if (c == a && a != -1) {
      cnt++;
      str = str.erase(i, 1);
    }
    if (c == b && b != -1) {
      cnt++;
      str = str.erase(i, 1);
    }
    if (cnt == need) break;
  }
  if (str.size() == 0) {
    str = "-1";
  } else {
    i = 0;
    while (str[i] == '0' && i < str.size()) i++;
    if (i == str.size())
      str = "0";
    else
      str = str.erase(0, i);
    sum = 0;
    for (i = 0; i < str.size(); i++) {
      c = str[i] - '0';
      sum += c;
    }
    if (sum % 3) str = "-1";
  }
  return str;
}
string find_beautiful(string str, vector<pair<int, int> > possible_forms) {
  string beautiful, ans;
  int max_len, len;
  ans = "-1";
  max_len = -1;
  for (auto form : possible_forms) {
    beautiful = make_beautiful(str, form);
    len = beautiful.size();
    if (len > max_len && beautiful != "-1") {
      ans = beautiful;
      max_len = beautiful.size();
    }
  }
  return ans;
}
int main() {
  int i, n, sum, k, leading, first;
  string str;
  init();
  cin >> str;
  n = str.size();
  sum = 0;
  for (i = 0; i < n; i++) {
    sum += (str[i] - '0');
  }
  if (sum % 3 == 0) {
    output = str;
  }
  if (sum % 3 == 1) {
    output = find_beautiful(str, mod1);
  }
  if (sum % 3 == 2) {
    output = find_beautiful(str, mod2);
  }
  cout << output << "\n";
  return 0;
}