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;
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
int dx[] = {-1, 0, 0, 1, 1, 1, -1, -1};
int dy[] = {0, 1, -1, 0, 1, -1, 1, -1};
bool readPoint(complex<long double> &p) {
  long double x, y;
  if (!(cin >> x >> y)) return 0;
  p = complex<long double>(x, y);
  return 1;
}
void printPoint(complex<long double> P) {
  cout << P.real() << " " << P.imag() << "\n";
}
void fixpoint(complex<long double> &p) {
  if (p.real() < 1e-4 && p.real() > -1e-4)
    p = complex<long double>(0, p.imag());
  if (p.imag() < 1e-4 && p.imag() > -1e-4)
    p = complex<long double>(p.real(), 0);
}
int dcmp(double x, double y) {
  return fabs(x - y) <= 1e-4 ? 0 : x < y ? -1 : 1;
}
bool pointOnSegment(complex<long double> a, complex<long double> b,
                    complex<long double> p) {
  return fabs(((conj(((b) - (a))) * (((p) - (a)))).imag())) < 1e-4 &&
         ((conj(((b) - (a))) * (((p) - (a)))).real()) > -1e-4 &&
         ((conj(((a) - (b))) * (((p) - (b)))).real()) > -1e-4;
}
long double getYfromXforline(complex<long double> a, complex<long double> b,
                             long double x) {
  if (a.real() == b.real()) return b.imag();
  long double m = (a.imag() - b.imag()) / (a.real() - b.real());
  long double c = a.imag() - m * a.real();
  return m * x + c;
}
long double getXfromYforline(complex<long double> a, complex<long double> b,
                             long double y) {
  if (a.real() == b.real()) return b.real();
  long double m = (a.imag() - b.imag()) / (a.real() - b.real());
  long double c = a.imag() - m * a.real();
  return (y - c) / m;
}
double getAngle_2vec(complex<long double> v1, complex<long double> v2) {
  return atan2(((conj(v1) * (v2)).imag()), ((conj(v1) * (v2)).real()));
}
double getMinAngle_2vec(complex<long double> v1, complex<long double> v2) {
  if (((conj(v1) * (v2)).imag()) >= 0)
    return atan2(((conj(v1) * (v2)).imag()), ((conj(v1) * (v2)).real()));
  return atan2(((conj(v2) * (v1)).imag()), ((conj(v2) * (v1)).real()));
}
complex<long double> getVectorWithLengthR(complex<long double> a,
                                          complex<long double> b, double r) {
  return complex<long double>(
      ((((b) - (a))) /
       ((long double)hypot((((b) - (a))).imag(), (((b) - (a))).real())))
              .real() *
          r,
      ((((b) - (a))) /
       ((long double)hypot((((b) - (a))).imag(), (((b) - (a))).real())))
              .imag() *
          r);
}
namespace std {
bool operator<(const complex<long double> &a, const complex<long double> &b) {
  return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
}
bool operator>(const complex<long double> &a, const complex<long double> &b) {
  return a.real() != b.real() ? a.real() > b.real() : a.imag() > b.imag();
}
bool operator<(const vector<complex<long double> > &a,
               const vector<complex<long double> > &b) {
  complex<long double> p(a[0].real(),
                         getYfromXforline(b[0], b[1], a[0].real()));
  if (pointOnSegment(b[0], b[1], p)) return a[0].imag() < p.imag();
  p = complex<long double>(a[1].real(),
                           getYfromXforline(b[0], b[1], a[1].real()));
  if (pointOnSegment(b[0], b[1], p)) return a[1] < p;
  p = complex<long double>(b[0].real(),
                           getYfromXforline(a[0], a[1], b[0].real()));
  if (pointOnSegment(a[0], a[1], p)) return p < b[0];
  p = complex<long double>(b[1].real(),
                           getYfromXforline(a[0], a[1], b[1].real()));
  if (pointOnSegment(a[0], a[1], p)) return p < b[1];
  return max(a[0].imag(), a[1].imag()) < max(b[0].imag(), b[1].imag());
}
}  // namespace std
complex<long double> getFurthPoint(complex<long double> a1,
                                   complex<long double> a2,
                                   complex<long double> b1,
                                   complex<long double> b2) {
  if (((((conj(((b1) - (a1))) * (((b1) - (a1)))).real())) < 1e-4))
    return a2 + ((b2) - (b1));
  if (((((conj(((b2) - (a1))) * (((b2) - (a1)))).real())) < 1e-4))
    return a2 + ((b1) - (b2));
  if (((((conj(((b1) - (a2))) * (((b1) - (a2)))).real())) < 1e-4))
    return a1 + ((b2) - (b1));
  return a1 + ((b1) - (b2));
}
struct point3D {
  long double x, y, z;
  point3D(){};
  point3D(long double x1, long double y1, long double z1) {
    x = x1;
    y = y1;
    z = z1;
  }
  bool read() {
    if (cin >> x >> y >> z) return 1;
    return 0;
  }
  long double dis(point3D other) {
    return sqrt(pow(x - other.x, 2) + pow(y - other.y, 2) +
                pow(z - other.z, 2));
  }
};
struct line {
  double a, b, c;
  line(complex<long double> p1, complex<long double> p2) {
    if (fabs(p1.real() - p2.real()) < 1e-4) {
      a = 1.0;
      b = 0.0;
      c = -p1.real();
    } else {
      a = -(double)(p1.imag() - p2.imag()) / (p1.real() - p2.real());
      b = 1.0;
      c = -(double)(a * p1.real()) - p1.imag();
    }
  }
};
bool areParallel2Lines(line l1, line l2) {
  return (fabs(l1.a - l2.a) < 1e-4) && (fabs(l1.b - l2.b) < 1e-4);
}
bool segmentIntersectSegment(complex<long double> a, complex<long double> b,
                             complex<long double> c, complex<long double> d,
                             complex<long double> &p) {
  line l1(a, b), l2(c, d);
  if (areParallel2Lines(l1, l2)) return false;
  long double x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b);
  if (fabs(l1.b) > 1e-4)
    p = complex<long double>(x, -(l1.a * x + l1.c));
  else
    p = complex<long double>(x, -(l2.a * x + l2.c));
  return pointOnSegment(a, b, p) && pointOnSegment(c, d, p);
}
bool pointInsidReqt(complex<long double> LL, complex<long double> RU,
                    complex<long double> P) {
  return P.real() >= LL.real() && P.real() <= RU.real() &&
         P.imag() >= LL.imag() && P.imag() <= RU.imag();
}
bool segmentIntersectReqtangle(complex<long double> LL, complex<long double> RU,
                               complex<long double> a, complex<long double> b) {
  complex<long double> LU = complex<long double>(LL.real(), RU.imag()),
                       RL = complex<long double>(RU.real(), LL.imag()), p;
  if (pointInsidReqt(LL, RU, a) || pointInsidReqt(LL, RU, b)) return 1;
  return segmentIntersectSegment(LU, RU, a, b, p) ||
         segmentIntersectSegment(LL, RL, a, b, p) ||
         segmentIntersectSegment(LL, LU, a, b, p) ||
         segmentIntersectSegment(RL, RU, a, b, p);
}
bool areSame2Lines(line l1, line l2) {
  return (fabs(l1.a - l2.a) < 1e-4) && (fabs(l1.b - l2.b) < 1e-4) &&
         (fabs(l1.c - l2.c) < 1e-4);
}
bool areIntersect2Lines(line l1, line l2, complex<long double> &p) {
  if (areParallel2Lines(l1, l2)) return false;
  long double x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b);
  if (fabs(l1.b) > 1e-4)
    p = complex<long double>(x, -(l1.a * x + l1.c));
  else
    p = complex<long double>(x, -(l2.a * x + l2.c));
  return true;
}
double waterFallOnsegments(vector<vector<complex<long double> > > v,
                           complex<long double> p) {
  for (int i = (int)v.size() - 1; i >= 0; i--) {
    double x = p.real(), y = getYfromXforline(v[i][0], v[i][1], p.real());
    if (y <= p.imag() &&
        pointOnSegment(v[i][0], v[i][1], complex<long double>(x, y))) {
      if (v[i][0].imag() < v[i][1].imag())
        p = v[i][0];
      else
        p = v[i][1];
    }
  }
  return p.real();
}
double pointDistToLineSegment(complex<long double> p, complex<long double> a,
                              complex<long double> b, complex<long double> &c) {
  complex<long double> ap = ((p) - (a)), ab = ((b) - (a));
  long double u = ((conj(ap) * (ab)).real()) / (((conj(ab) * (ab)).real()));
  if (u < 0.0) {
    c = complex<long double>(a.real(), a.imag());
    return ((long double)hypot((p - a).imag(), (p - a).real()));
  }
  if (u > 1.0) {
    c = complex<long double>(b.real(), b.imag());
    return ((long double)hypot((p - b).imag(), (p - b).real()));
  }
  c = (a + complex<long double>(ab.real() * u, ab.imag() * u));
  return ((long double)hypot((p - c).imag(), (p - c).real()));
}
double pointDistToLine(complex<long double> p, complex<long double> a,
                       complex<long double> b, complex<long double> &c) {
  complex<long double> ap = ((p) - (a)), ab = ((b) - (a));
  long double u = ((conj(ap) * (ab)).real()) / (((conj(ab) * (ab)).real()));
  c = (a + complex<long double>(ab.real() * u, ab.imag() * u));
  return ((long double)hypot((p - c).imag(), (p - c).real()));
}
const int N = 1e5 + 5, mod = 1000000007;
int n, mem[N][2][3];
string s;
int solve(int i, int stat, int md) {
  if (i == n) {
    if (md) return 1e9;
    return 0;
  }
  int &ret = mem[i][stat][md];
  if (~ret) return ret;
  if (stat || s[i] != '0')
    return ret = min(1 + solve(i + 1, stat, md),
                     solve(i + 1, 1, (md + s[i] - '0') % 3));
  return ret = min(1 + solve(i + 1, 0, 0), n - i - 1);
}
void build(int i, int stat, int md) {
  if (i == n) return;
  int &ret = mem[i][stat][md];
  if (stat || s[i] != '0') {
    if (ret == 1 + solve(i + 1, stat, md)) {
      build(i + 1, stat, md);
      return;
    }
    cout << s[i];
    build(i + 1, 1, (md + s[i] - '0') % 3);
    return;
  }
  if (ret == 1 + solve(i + 1, 0, 0))
    build(i + 1, 0, 0);
  else
    cout << 0;
}
int main() {
  file();
  fast();
  cin >> s;
  n = s.size();
  memset(mem, -1, sizeof mem);
  if (solve(0, 0, 0) == n) return cout << -1, 0;
  build(0, 0, 0);
}