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 ll = long long;
using ld = long double;
using namespace std;
void debugi(vector<int>& vec) {
  int n = (int)vec.size();
  for (int i = 0; i < n; i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
}
void debugd(vector<long double>& vec) {
  int n = (int)vec.size();
  for (int i = 0; i < n; i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
}
void debugl(vector<ll>& vec) {
  int n = (int)vec.size();
  for (int i = 0; i < n; i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
}
void debugmap(map<int, int>& mp) {
  for (auto x : mp) {
    cout << x.first << " " << x.second << " , ";
  }
  cout << endl;
}
void debugset(set<int>& st) {
  for (auto x : st) {
    cout << x << " ";
  }
  cout << endl;
}
void debugparri(vector<pair<int, int>>& arr) {
  for (int i = 0; i < (int)arr.size(); i++) {
    cout << "[" << arr[i].first << " : " << arr[i].second << "]"
         << " ";
  }
  cout << endl;
}
void debugpi(pair<int, int>& pi) {
  cout << pi.first << " " << pi.second << endl;
}
void debugq(queue<int> q) {
  while (!q.empty()) {
    cout << q.front() << " ";
    q.pop();
  }
  cout << endl;
}
bool check(int n, int i, int j) {
  if ((0 <= i & i < n) && (0 <= j & j < n)) {
    return true;
  }
  return false;
}
ll MOD = 1e9 + 7;
ll powab(ll a, ll b, ll mod) {
  if (b == 0) {
    return 1;
  }
  ll z = powab(a, b / 2, mod);
  ll res = (z * z * 1LL) % mod;
  if (b & 1) {
    res = (res * 1LL * a) % mod;
  }
  return res;
}
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
void upd(int k, int x, vector<int>& tree, int n) {
  if (k == 0) {
    return;
  }
  while (k <= n) {
    tree[k] += x;
    k += (k & -k);
  }
}
int sum(int k, vector<int>& tree, int n) {
  int s = 0;
  while (k >= 1) {
    s += tree[k];
    k -= (k & -k);
  }
  return s;
}
ll mod = 998244353;
void solve() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(n);
  vector<vector<int>> dp(3);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    a[i] = s[i] - '0';
    int rem = a[i] % 3;
    sum += a[i];
    dp[rem].push_back(i);
  }
  if (sum % 3 == 0) {
    cout << s << endl;
    return;
  }
  if (sum % 3 == 1) {
    vector<char> ans1, ans2;
    int len1 = 0, len2 = 0, m1 = 0, m2 = 0;
    if (dp[1].size() != 0) {
      int last = dp[1].size();
      int remove = dp[1][last - 1];
      for (int i = 0; i < n; i++) {
        if (i == remove) {
          continue;
        }
        ans1.push_back(s[i]);
      }
      m1 = ans1.size();
      int j = 0;
      for (int i = 0; i < m1; i++) {
        if (ans1[i] == '0') {
          j += 1;
        } else {
          break;
        }
      }
      len1 = m1 - j;
    }
    if (dp[2].size() < 2) {
      len2 = 0;
    } else {
      int k = dp[2].size();
      int rem1 = dp[2][k - 1], rem2 = dp[2][k - 2];
      for (int i = 0; i < n; i++) {
        if (i == rem1 || i == rem2) {
          continue;
        }
        ans2.push_back(s[i]);
      }
      m2 = ans2.size();
      int j = 0;
      for (int i = 0; i < m2; i++) {
        if (ans2[i] == '0') {
          j += 1;
        } else {
          break;
        }
      }
      len2 = m2 - j;
    }
    if (len1 > len2) {
      int j = 0;
      for (int i = 0; i < m1; i++) {
        if (ans1[i] == '0') {
          j += 1;
          continue;
        }
        break;
      }
      for (int i = j; i < m1; i++) {
        cout << ans1[i];
      }
      cout << endl;
      return;
    }
    if (len2 == 0 && len1 == 0) {
      if (m2 != 0) {
        cout << '0' << endl;
        return;
      }
      if (m1 != 0) {
        cout << '0' << endl;
        return;
      }
      cout << -1 << endl;
      return;
    }
    int j = 0;
    for (int i = 0; i < m2; i++) {
      if (ans2[i] == '0') {
        j += 1;
        continue;
      }
      break;
    }
    for (int i = j; i < m2; i++) {
      cout << ans2[i];
    }
    cout << endl;
    return;
  }
  if (sum % 3 == 2) {
    vector<char> ans1, ans2;
    int len1 = 0, len2 = 0, m1 = 0, m2 = 0;
    if (dp[2].size() != 0) {
      int last = dp[2].size();
      int remove = dp[2][last - 1];
      for (int i = 0; i < n; i++) {
        if (i == remove) {
          continue;
        }
        ans1.push_back(s[i]);
      }
      m1 = ans1.size();
      int j = 0;
      for (int i = 0; i < m1; i++) {
        if (ans1[i] == '0') {
          j += 1;
        } else {
          break;
        }
      }
      len1 = m1 - j;
    }
    if (dp[1].size() < 2) {
      len2 = 0;
    } else {
      int k = dp[1].size();
      int rem1 = dp[1][k - 1], rem2 = dp[1][k - 2];
      for (int i = 0; i < n; i++) {
        if (i == rem1 || i == rem2) {
          continue;
        }
        ans2.push_back(s[i]);
      }
      m2 = ans2.size();
      int j = 0;
      for (int i = 0; i < m2; i++) {
        if (ans2[i] == '0') {
          j += 1;
        } else {
          break;
        }
      }
      len2 = m2 - j;
    }
    if (len1 > len2) {
      int j = 0;
      for (int i = 0; i < m1; i++) {
        if (ans1[i] == '0') {
          j += 1;
          continue;
        }
        break;
      }
      for (int i = j; i < m1; i++) {
        cout << ans1[i];
      }
      cout << endl;
      return;
    }
    if (len2 == 0 && len1 == 0) {
      if (m2 != 0) {
        cout << '0' << endl;
        return;
      }
      if (m1 != 0) {
        cout << '0' << endl;
        return;
      }
      cout << -1 << endl;
      return;
    }
    int j = 0;
    for (int i = 0; i < m2; i++) {
      if (ans2[i] == '0') {
        j += 1;
        continue;
      }
      break;
    }
    for (int i = j; i < m2; i++) {
      cout << ans2[i];
    }
    cout << endl;
    return;
  }
  cout << -1 << endl;
  return;
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  for (int tt = 0; tt < t; tt++) {
    solve();
  }
  return 0;
}