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 JAVA):

Solution:
import java.util.*;
import static java.lang.Math.*;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

public class A {

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int k) {
			x = d;
			y = k;
		}

		@Override
		public int compareTo(pair arg0) {
			// TODO Auto-generated method stub
			if (x == arg0.x) {
				return y - arg0.y;
			}
			return x - arg0.x;
		}
	}

	static PrintWriter pw;
	static int n;
	static int m;

	static int bin(int num) {
		int s = 0;
		int e = a.length - 1;
		int ans = -1;
		while (s <= e) {
			int mid = (s + e) / 2;
			if (a[mid] <= num) {
				s = mid + 1;
				ans = mid;
			} else
				e = mid - 1;
		}
		return ans;
	}

	static int[][][] memo;

	static int dp(int mod, int idx, int f) {
		if (idx == a.length && mod == 0)
			return 0;
		if (idx == a.length)
			return 1000000000;
		if (memo[f][mod][idx] != -1)
			return memo[f][mod][idx];
		if (a[idx] == '0' && f == 0)
			return memo[f][mod][idx] = 1 + dp(mod, idx + 1, 0);

		int t = dp((mod + a[idx] - '0') % 3, idx + 1, 1);

		int l = 1 + dp(mod, idx + 1, f);

		return memo[f][mod][idx] = Math.min(t, l);
	}

	static ArrayList<Character> arr;

	static void track(int ans, int idx, int mod, int f) {
		if (idx == a.length)
			return;
		if (a[idx] == '0' && f == 0)
			track(ans - 1, idx + 1, mod, f);
		else if (ans == dp((mod + a[idx] - '0') % 3, idx + 1, 1)) {
//			System.out.println(idx);
			arr.add(a[idx]);
			track(ans, idx + 1, (mod + a[idx] - '0') % 3, 1);
		} else {
			track(ans - 1, idx+1, mod, f);
		}
	}

	static char[] a;

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(System.out);
//		StringTokenizer st = new StringTokenizer(br.readLine());
//		n = Integer.parseInt(st.nextToken());
		a = br.readLine().toCharArray();
		memo = new int[2][3][a.length];
		for (int i = 0; i < 3; i++) {
			Arrays.fill(memo[0][i], -1);
			Arrays.fill(memo[1][i], -1);
		}
		boolean f = false;
		for (int j = 0; j < a.length; j++) {
			if (a[j] == '0')
				f = true;
		}
		int ans = dp(0, 0, 0);
//		System.out.println(ans);
		arr = new ArrayList<>();
		if (ans == a.length)
			if (f)
				pw.println(0);
			else
				pw.println(-1);
		else {
//			System.out.println(dp(2,2));
			track(ans, 0 , 0 ,0);
			for (char c : arr) {
				pw.print(c);
			}
		}
		pw.flush();
		pw.close();

	}

	static boolean check(String s, int h, int m) {
		String s2 = reversString(m + "") + ":" + reversString(h + "");
		return s2.equals(com(h, m));

	}

	static String com(int h, int m) {
		String s = "";
		if (h < 10)
			s += "0" + h;
		else {
			s += h;
		}
		s += ":";
		if (m < 10)
			s += "0" + m;
		else {
			s += m;
		}
		return s;
	}

	static String reversString(String x) {
		int y = Integer.parseInt(x);
		if (y < 10)
			return x + "0";
		else
			return x.charAt(1) + "" + x.charAt(0);
	}

	static boolean[] vis;
	static ArrayList<Integer>[] g;
	static ArrayList<Integer> r;
	static int[] sta;
	static int[] end;

//	static void dfs(int n) {
//		vis[n] = true;
//		for (int v : g[n]) {
//			boolean f = false;
//			if (!vis[v]) {
//				p.add(new triple(n + 1, v + 1));
//				f = true;
//				dfs(v);
//				break;
//			}
//			if (!f) {
//				p.add(new triple(n + 1, g[n].get(0) + 1));
//			}
//		}
//	}

	static void bfs(int s) {
		Queue<triple> q = new LinkedList<triple>();
		q.add(new triple(s, 1, 0, 0));
		vis[s] = true;
		while (!q.isEmpty()) {
			triple p = q.remove();
			int u = p.x;
			int c = p.y;
			int even = p.z;
			int odd = p.w;
//			System.out.println(odd + " " + even);
			if (c == 0) {
				int l = even % 2 == 1 ? 1 - sta[u] : sta[u];
				if (l == end[u]) {
					for (int v : g[u]) {

						if (!vis[v]) {
							vis[v] = true;
							q.add(new triple(v, 1 - c, even, odd));
						}
					}

				} else {
					r.add(u + 1);
					even = 1 - even;
					for (int v : g[u]) {

						if (!vis[v]) {
							vis[v] = true;
							q.add(new triple(v, 1 - c, even, odd));
						}
					}
				}

			} else {
				int l = odd % 2 == 1 ? 1 - sta[u] : sta[u];
				if (l == end[u]) {
					for (int v : g[u]) {

						if (!vis[v]) {
							vis[v] = true;
							q.add(new triple(v, 1 - c, even, odd));
						}
					}

				} else {
					r.add(u + 1);
					odd = 1 - odd;
					for (int v : g[u]) {

						if (!vis[v]) {
							vis[v] = true;
							q.add(new triple(v, 1 - c, even, odd));
						}
					}
				}
			}
		}

	}

	static class triple implements Comparable<triple> {
		int x;
		int y;
		int z;
		int w;

		public triple(int a, int b, int c, int d) {
			x = a;
			y = b;
			z = c;
			w = d;
		}

		@Override
		public int compareTo(triple o) {
			// TODO Auto-generated method stub
			return y - o.y;
		}
	}

	static long pow(long a, long e) // O(log e)
	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res *= a;
			a *= a;
			e >>= 1;
		}
		return res;
	}

	static long gcd(long a, long b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

}