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 int power(long long int a, long long int b) {
  long long int result = 1;
  while (b > 0) {
    int lastbit = (b & 1);
    if (lastbit) {
      result = (result * a);
    }
    a = (a * a);
    b = b >> 1;
  }
  return result;
}
long long int power2(long long int a, long long int b, long long int p) {
  long long int result = 1;
  while (b > 0) {
    int lastbit = (b & 1);
    if (lastbit) {
      result = (result * a) % p;
    }
    a = (a * a) % p;
    b = b >> 1;
  }
  return result % p;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<int> SieveOfEratosthenes(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  vector<int> v;
  v.push_back(0);
  for (int p = 2; p <= n; p++)
    if (prime[p]) v.push_back(p);
  return v;
}
void shortest(map<int, vector<pair<int, long long int>>> m, int src, int n,
              long long int *dist) {
  bool visited[n + 1];
  set<pair<long long int, int>> s;
  for (int i = 0; i <= n; i++) {
    dist[i] = -1;
    visited[i] = false;
  }
  s.insert(make_pair(0ll, src));
  dist[src] = 0;
  while (!s.empty()) {
    auto t = s.begin();
    long long int dis = (*t).first;
    int u = (*t).second;
    s.erase(t);
    if (visited[u]) {
      continue;
    }
    visited[u] = true;
    for (auto tt : m[u]) {
      int v = tt.first;
      long long int w = tt.second;
      if (!visited[v]) {
        if (dist[v] != -1 && dist[v] > dis + w) {
          s.erase(make_pair(dist[v], v));
          dist[v] = dis + w;
          s.insert(make_pair(dist[v], v));
        } else if (dist[v] == -1) {
          dist[v] = dis + w;
          s.insert(make_pair(dist[v], v));
        }
      }
    }
  }
}
string fun(int n, string s, int one, int val) {
  bool visited[n];
  memset(visited, 0, sizeof(visited));
  string ans = "";
  for (int i = n - 1; i >= 0; i--) {
    int t = s[i] - '0';
    t %= 3;
    if (t == val && one) {
      visited[i] = 1;
      one--;
    }
  }
  int i = 0;
  for (; i < n; i++) {
    int t = s[i] - '0';
    if (!visited[i] && t > 0) {
      break;
    }
  }
  for (; i < n; i++) {
    if (!visited[i]) ans += s[i];
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tttt = 1;
  for (int ttt = 1; ttt <= tttt; ttt++) {
    string s;
    cin >> s;
    int n = s.size();
    int one = 0, two = 0, three = 0, zero = 0;
    for (int i = 0; i < n; i++) {
      int t = s[i] - '0';
      if (t != 0) {
        t %= 3;
        if (t == 0) {
          three++;
        } else if (t == 1) {
          one++;
        } else {
          two++;
        }
      } else {
        zero++;
      }
    }
    string ans = "";
    int o = one % 3;
    int t = two % 3;
    if (o >= t) {
      o -= t;
      if (o == 1) {
        ans = fun(n, s, 1, 1);
        if (two > 1) {
          string ans1 = fun(n, s, 2, 2);
          if (ans1.size() > ans.size()) {
            ans = ans1;
          }
        }
      } else if (o == 2) {
        if (two > 0) {
          ans = fun(n, s, 1, 2);
        } else {
          ans = fun(n, s, 2, 1);
        }
      } else {
        ans = fun(n, s, 0, 1);
      }
    } else {
      t -= o;
      if (t == 1) {
        ans = fun(n, s, 1, 2);
        if (one > 1) {
          string ans1 = fun(n, s, 2, 1);
          if (ans1.size() > ans.size()) {
            ans = ans1;
          }
        }
      } else if (t == 2) {
        if (one > 0) {
          ans = fun(n, s, 1, 1);
        } else {
          ans = fun(n, s, 2, 2);
        }
      } else {
        ans = fun(n, s, 0, 2);
      }
    }
    if (ans.size() == 0) {
      if (zero) {
        ans = "0";
      } else {
        ans = "-1";
      }
    }
    cout << ans;
    cout << endl;
  }
  return 0;
}