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 FAT_BS(long long a, long long b, long long aa[], long long x) {
  while (a <= b) {
    long long mid = (a + b) / 2;
    if (aa[mid] == x)
      return 1;
    else if (aa[mid] > x)
      b = mid - 1;
    else
      a = mid + 1;
  }
  return -1;
}
long long FAT_gcd(long long a, long long b) {
  if (a == 0)
    return b;
  else
    return FAT_gcd(b % a, a);
}
long long FAT_prime(long long x) {
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) return 0;
  }
  return 1;
}
void FAT_swap(char *x, char *y) {
  char temp;
  temp = *x;
  *x = *y;
  *y = temp;
}
long long FAT_big_mod(long long b, long long p, long long m) {
  if (p == 0)
    return 1;
  else if (p % 2 == 0) {
    long long k = FAT_big_mod(b, p / 2, m);
    return (k * k) % m;
  } else
    return ((b % m) * (FAT_big_mod(b, p - 1, m))) % m;
}
long long FAT_josephus(long long n, long long k) {
  if (n == 1) return 1;
  return (FAT_josephus(n - 1, k) + k - 1) % n + 1;
}
long long FAT_gcdExtended(long long a, long long b, long long *x,
                          long long *y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = FAT_gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long a1[12];
bool vis[100010];
int main() {
  string s1;
  cin >> s1;
  long long sz = s1.size();
  long long cnt = 0;
  bool f = 1;
  memset(a1, 0, sizeof(a1));
  memset(vis, 0, sizeof(vis));
  for (long long i = 0; i < sz; i++) {
    cnt += s1[i] - '0';
    a1[s1[i] - '0']++;
    if (s1[i] == '0') f = 0;
  }
  bool ff = 0;
  long long rem = cnt % 3;
  if (rem == 0)
    cout << s1 << endl;
  else {
    if (rem == 1) {
      long long mx1 = 0, mx2 = 0, p = 1, q = 1;
      long long sz1, sz2;
      string s2, s3;
      if ((a1[1] + a1[4] + a1[7]) >= 1) {
        long long c = 0;
        for (long long i = sz - 1; i >= 0; i--) {
          if (s1[i] == '1' || s1[i] == '4' || s1[i] == '7') {
            vis[i] = 1;
            c++;
          }
          if (c == 1) break;
        }
        for (long long i = 0; i < sz; i++) {
          if (!vis[i]) s2 += s1[i];
        }
        sz1 = s2.size();
        long long i = 0;
        while (s2[i] == '0' && i < sz1) i++;
        if (i < sz1) {
          ff = 1;
          q = 0;
          mx1 = sz1 - i;
        }
      }
      if ((a1[2] + a1[5] + a1[8]) >= 2) {
        long long c = 0;
        memset(vis, 0, sizeof(vis));
        for (long long i = sz - 1; i >= 0; i--) {
          if (s1[i] == '2' || s1[i] == '5' || s1[i] == '8') vis[i] = 1, c++;
          if (c == 2) break;
        }
        for (long long i = 0; i < sz; i++) {
          if (!vis[i]) s3 += s1[i];
        }
        sz2 = s3.size();
        long long i = 0;
        while (s3[i] == '0' && i < sz2) i++;
        if (i < sz2) {
          ff = 1;
          p = 0;
          mx2 = sz2 - i;
        }
      }
      if (!p && !q) {
        if (mx1 > mx2) {
          long long i = sz1 - mx1;
          for (; i < sz1; i++) cout << s2[i];
          cout << endl;
        } else {
          long long i = sz2 - mx2;
          for (; i < sz2; i++) cout << s3[i];
          cout << endl;
        }
      } else if (!p || !q) {
        if (p == 0) {
          long long i = sz2 - mx2;
          for (; i < sz2; i++) cout << s3[i];
          cout << endl;
        }
        if (q == 0) {
          long long i = sz1 - mx1;
          for (; i < sz1; i++) cout << s2[i];
          cout << endl;
        }
      }
    } else if (rem == 2) {
      long long mx1 = 0, mx2 = 0, p = 1, q = 1;
      long long sz1, sz2;
      string s2, s3;
      if ((a1[2] + a1[8] + a1[5]) >= 1) {
        long long c = 0;
        for (long long i = sz - 1; i >= 0; i--) {
          if (s1[i] == '2' || s1[i] == '8' || s1[i] == '5') {
            vis[i] = 1;
            c++;
          }
          if (c == 1) break;
        }
        for (long long i = 0; i < sz; i++) {
          if (!vis[i]) s2 += s1[i];
        }
        sz1 = s2.size();
        long long i = 0;
        while (s2[i] == '0' && i < sz1) i++;
        if (i < sz1) {
          ff = 1, q = 0;
          mx1 = sz1 - i;
        }
      }
      if ((a1[1] + a1[4] + a1[7]) >= 2) {
        long long c = 0;
        memset(vis, 0, sizeof(vis));
        for (long long i = sz - 1; i >= 0; i--) {
          if (s1[i] == '1' || s1[i] == '4' || s1[i] == '7') {
            vis[i] = 1;
            c++;
          }
          if (c == 2) break;
        }
        for (long long i = 0; i < sz; i++) {
          if (!vis[i]) s3 += s1[i];
        }
        sz2 = s3.size();
        long long i = 0;
        while (s3[i] == '0' && i < sz2) i++;
        if (i < sz2) {
          ff = 1, p = 0;
          mx2 = sz2 - i;
        }
      }
      if (!p && !q) {
        if (mx1 > mx2) {
          long long i = sz1 - mx1;
          for (; i < sz1; i++) cout << s2[i];
          cout << endl;
        } else {
          long long i = sz2 - mx2;
          for (; i < sz2; i++) cout << s3[i];
          cout << endl;
        }
      } else if (!p || !q) {
        if (p == 0) {
          long long i = sz2 - mx2;
          for (; i < sz2; i++) cout << s3[i];
          cout << endl;
        }
        if (q == 0) {
          long long i = sz1 - mx1;
          for (; i < sz1; i++) cout << s2[i];
          cout << endl;
        }
      }
    }
    if (!ff) {
      if (!f)
        cout << "0" << endl;
      else
        cout << "-1" << endl;
    }
  }
  return 0;
}