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>
#pragma GCC optimize("Ofast")
using namespace std;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e % 2)
    return ((b * power((b) * (b), (e - 1) / 2)));
  else
    return power((b) * (b), e / 2);
}
long long modpower(long long b, long long e, long long q) {
  long long MOD = q;
  if (e == 0) return 1;
  if (e % 2)
    return ((b % MOD) * modpower((b % MOD) * (b % MOD), (e - 1) / 2, q)) % MOD;
  else
    return modpower((b % MOD) * (b % MOD), e / 2, q) % MOD;
}
void dpv(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << '\n';
}
void dpv(vector<pair<long long, long long> > v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << '\n';
  }
}
void dpv(set<long long> v) {
  for (auto i : v) {
    cout << i << " ";
  }
  cout << '\n';
}
long long md = 1e9 + 7;
map<long long, long long> m;
long long inv[51];
long long C(long long n, long long r) {
  if (r > n) return 0;
  if (n - r < r) r = n - r;
  n %= md;
  long long ans = 1;
  for (long long i = 0; i < r; i++) {
    ans = (ans * (n - i)) % md;
    ans = (ans * inv[i + 1]) % md;
  }
  return ans;
}
void pre() {
  for (long long i = 1; i <= 50; i++) inv[i] = modpower(i, md - 2, md);
}
void rec(long long i, vector<long long> v, long long coeff, long long power) {
  if (i == ((long long)(v).size())) {
    m[power] += coeff;
    m[power] %= md;
  } else {
    rec(i + 1, v, coeff, power);
    long long ncoeff = -1 * coeff;
    ncoeff %= md;
    if (ncoeff < 0) {
      ncoeff += md;
    }
    rec(i + 1, v, ncoeff, power + v[i] + 1);
  }
}
void oblivious() {
  string s;
  cin >> s;
  long long n = s.length();
  long long s1 = 0;
  long long p1 = 0;
  long long p2 = 0;
  long long p3 = 0;
  string s2;
  for (long long i = 0; i < s.length(); i++) {
    s1 += s[i] - '0';
    if ((s[i] - '0') % 3 == 1) {
      p1++;
    } else if ((s[i] - '0') % 3 == 2) {
      p2++;
    } else {
      p3++;
    }
  }
  long long z = s1 % 3;
  if (z == 0) {
    cout << s << '\n';
  } else if (z == 1 && (p1 >= 1 || p2 >= 2)) {
    if (p1 >= 1) {
      long long c = 0;
      for (long long i = n - 1; i >= 0; i--) {
        if ((s[i] - '0') % 3 == 1 && c == 0) {
          c++;
          continue;
        } else {
          s2.push_back(s[i]);
        }
      }
      reverse(s2.begin(), s2.end());
    }
    string s3;
    if (p2 >= 2) {
      long long c = 0;
      for (long long i = n - 1; i >= 0; i--) {
        if ((s[i] - '0') % 3 == 2 && (c == 0 || c == 1)) {
          c++;
          continue;
        } else {
          s3.push_back(s[i]);
        }
      }
      reverse(s3.begin(), s3.end());
    }
    if (!s3.empty()) {
      long long f = 1;
      while (s2[0] == '0') {
        f = 0;
        s2.erase(s2.begin());
      }
      f = 1;
      while (s3[0] == '0') {
        f = 0;
        s3.erase(s3.begin());
      }
      string ans = (s3.length() > s2.length()) ? s3 : s2;
      if (ans.empty() && !f) {
        cout << "0" << '\n';
      } else if (ans.empty()) {
        cout << "-1" << '\n';
      } else {
        cout << ans << '\n';
      }
    } else {
      long long f = 1;
      while (s2[0] == '0') {
        f = 0;
        s2.erase(s2.begin());
      }
      string ans = s2;
      if (ans.empty() && !f) {
        cout << "0" << '\n';
      } else if (ans.empty()) {
        cout << "-1" << '\n';
      } else {
        cout << ans << '\n';
      }
    }
  } else if (z == 2 && (p1 >= 2 || p2 >= 1)) {
    string s3;
    if (p2 >= 1) {
      long long c = 0;
      for (long long i = n - 1; i >= 0; i--) {
        if ((s[i] - '0') % 3 == 2 && c == 0) {
          c++;
          continue;
        } else {
          s2.push_back(s[i]);
        }
      }
      reverse(s2.begin(), s2.end());
    }
    if (p1 >= 2) {
      long long c = 0;
      for (long long i = n - 1; i >= 0; i--) {
        if ((s[i] - '0') % 3 == 1 && (c == 0 || c == 1)) {
          c++;
          continue;
        } else {
          s3.push_back(s[i]);
        }
      }
      reverse(s3.begin(), s3.end());
    }
    if (!s3.empty()) {
      long long f = 1;
      while (s2[0] == '0') {
        f = 0;
        s2.erase(s2.begin());
      }
      f = 1;
      while (s3[0] == '0') {
        f = 0;
        s3.erase(s3.begin());
      }
      string ans = (s3.length() > s2.length()) ? s3 : s2;
      if (ans.empty() && !f) {
        cout << "0" << '\n';
      } else if (ans.empty()) {
        cout << "-1" << '\n';
      } else {
        cout << ans << '\n';
      }
    } else {
      long long f = 1;
      while (s2[0] == '0') {
        f = 0;
        s2.erase(s2.begin());
      }
      string ans = s2;
      if (ans.empty() && !f) {
        cout << "0" << '\n';
      } else if (ans.empty()) {
        cout << "-1" << '\n';
      } else {
        cout << ans << '\n';
      }
    }
  } else {
    cout << "-1" << '\n';
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    oblivious();
  }
  return 0;
}