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 spf[10];
long long fac[10];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < 10; i++) spf[i] = i;
  for (long long i = 4; i < 10; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < 10; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < 10; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
map<long long, long long> getfactor(long long a) {
  map<long long, long long> m;
  while (a > 1) {
    m[spf[a]]++;
    a /= spf[a];
  }
  return m;
}
long long power(long long x, long long y) {
  long long res = 1;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long inverse(long long a, long long p) { return power(a, p - 2); }
long long ncr(long long n, long long r, long long p) {
  if (r == 0) return 1;
  return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;
}
void solve() {
  string s;
  cin >> s;
  long long ss = s.size();
  long long a[ss];
  bool vis1[ss + 1], vis2[ss + 1];
  memset(vis1, false, sizeof(vis1));
  memset(vis2, false, sizeof(vis2));
  long long sum = 0;
  for (long long i = 0; i < ss; i++) {
    sum += s[i] - '0';
    a[i] = (s[i] - '0') % 3;
  }
  sum = sum % 3;
  if (sum == 0) {
    cout << s << '\n';
  } else if (sum == 1) {
    string s1, s2;
    long long count = 0;
    for (long long i = ss - 1; i >= 0; i--) {
      if (a[i] == 1) {
        vis1[i] = true;
        count++;
        break;
      }
    }
    if (count > 0) {
      count = 0;
      for (long long i = 0; i < ss; i++) {
        if (vis1[i] == true)
          count++;
        else if (s[i] == '0' && i == count && count >= 1) {
          count++;
          vis1[i] = true;
        } else
          s1.push_back(s[i]);
      }
      if (s1.size() == 0 && s[ss - 1] == '0' && vis1[ss - 1] == true)
        s1.push_back('0');
    }
    count = 0;
    for (long long i = ss - 1; i >= 0; i--) {
      if (a[i] == 2) {
        count++;
        vis2[i] = true;
      }
      if (count == 2) break;
    }
    if (count == 2) {
      count = 0;
      for (long long i = 0; i < ss; i++) {
        if (vis2[i] == true)
          count++;
        else if (s[i] == '0' && i == count && count >= 2) {
          count++;
          vis2[i] = true;
        } else
          s2.push_back(s[i]);
      }
      if (s2.size() == 0 && s[ss - 1] == '0' && vis2[ss - 1] == true)
        s2.push_back('0');
    }
    if (s1.size() == 0 && s2.size() == 0)
      cout << -1 << '\n';
    else if (s1.size() > s2.size()) {
      if (s1[0] == '0') {
        long long count1 = -1;
        for (long long i = 0; i < s1.size(); i++) {
          if (s1[i] != '0') {
            count1++;
            cout << s1[i];
          } else if (s1[i] == '0' && count1 >= 0)
            cout << s1[i];
        }
        if (count1 == -1) cout << 0;
        cout << '\n';
      } else
        cout << s1 << '\n';
    } else {
      if (s2[0] == '0') {
        long long count1 = -1;
        for (long long i = 0; i < s2.size(); i++) {
          if (s2[i] != '0') {
            count1++;
            cout << s2[i];
          } else if (s2[i] == '0' && count1 >= 0)
            cout << s2[i];
        }
        if (count1 == -1) cout << 0;
        cout << '\n';
      } else
        cout << s2 << '\n';
    }
  } else if (sum == 2) {
    string s1, s2;
    long long count = 0;
    for (long long i = ss - 1; i >= 0; i--) {
      if (a[i] == 2) {
        vis2[i] = true;
        count++;
        break;
      }
    }
    if (count > 0) {
      count = 0;
      for (long long i = 0; i < ss; i++) {
        if (vis2[i] == true)
          count++;
        else if (s[i] == '0' && i == count && count >= 1) {
          count++;
          vis2[i] = true;
        } else
          s2.push_back(s[i]);
      }
      if (s2.size() == 0 && s[ss - 1] == '0' && vis2[ss - 1] == true)
        s2.push_back('0');
    }
    count = 0;
    for (long long i = ss - 1; i >= 0; i--) {
      if (a[i] == 1) {
        count++;
        vis1[i] = true;
      }
      if (count == 2) break;
    }
    if (count == 2) {
      count = 0;
      for (long long i = 0; i < ss; i++) {
        if (vis1[i] == true)
          count++;
        else if (s[i] == '0' && i == count && count >= 2) {
          count++;
          vis1[i] = true;
        } else
          s1.push_back(s[i]);
      }
      if (s1.size() == 0 && s[ss - 1] == '0' && vis1[ss - 1] == true)
        s1.push_back('0');
    }
    if (s1.size() == 0 && s2.size() == 0)
      cout << -1 << '\n';
    else if (s1.size() > s2.size()) {
      if (s1[0] == '0') {
        long long count1 = -1;
        for (long long i = 0; i < s1.size(); i++) {
          if (s1[i] != '0') {
            count1++;
            cout << s1[i];
          } else if (s1[i] == '0' && count1 >= 0)
            cout << s1[i];
        }
        if (count1 == -1) cout << 0;
        cout << '\n';
      } else
        cout << s1 << '\n';
    } else {
      if (s2[0] == '0') {
        long long count1 = -1;
        for (long long i = 0; i < s2.size(); i++) {
          if (s2[i] != '0') {
            count1++;
            cout << s2[i];
          } else if (s2[i] == '0' && count1 >= 0)
            cout << s2[i];
        }
        if (count1 == -1) cout << 0;
        cout << '\n';
      } else
        cout << s2 << '\n';
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}