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:
//	package Assignment7;
	
	import java.io.BufferedReader;
	import java.io.InputStreamReader;
	import java.io.PrintWriter;
	import java.math.BigInteger;
	import java.util.Arrays;
	
	public class Problem2Again {
		static int[][] dp;
		static String s;
	
		public static void main(String[] args) throws Exception {
			dp = new int[(int) 1e6][3];
			for (int i = 0; i < dp.length; i++) {
				Arrays.fill(dp[i], -1);
			}
			PrintWriter pw = new PrintWriter(System.out);
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
			s = bf.readLine();
			int sum = 0;
			int[] arr = new int[10];
			for (int i = 0; i < s.length(); i++) {
				sum = (sum + (((int) s.charAt(i)) % 3)) % 3;
				arr[(int) s.charAt(i) - '0']++;
			}
			if (sum == 0) {
				pw.println(s);
			} else {
				dp(0, 0);
				Print(0, 0);
				String ans2="";
				if (sum == 1) {
					int index = 0;
					if (arr[1] > 0 && s.length() == 1) {
						//pw.println(-1);
					} else if (arr[1] > 0) {// remove the first one I see
						StringBuilder sb = new StringBuilder();
						for (int i = s.length() - 1; i >= 0; i--) {
							if (s.charAt(i) == '1') {
								index = i;
								break;
							}
						}
						if (index == 0) {
							ans2=remove_leadng_zeroes(0, s.substring(1));
							
						} else {
							if (index < s.length() - 1)
								ans2=s.substring(0, index) + s.substring(index + 1);
								
							else
								ans2=s.substring(0, index);
								//pw.println();
						}
	
					} 
				} else {
					// remainder can be 1 1 or 2
					int index = 0;
					 if (arr[2] > 0) {
						StringBuilder sb = new StringBuilder();
						for (int i = s.length() - 1; i >= 0; i--) {
							if (s.charAt(i) == '2') {
								index = i;
								break;
							}
						}
						if (index == 0) {
							ans2=remove_leadng_zeroes(0, s.substring(1));
							//pw.println();
						} else {
							if (index < s.length() - 1)
								ans2=s.substring(0, index) + s.substring(index + 1);
								//pw.println();
							else
								ans2=s.substring(0, index);
								//pw.println();
						}
	
					} else if (arr[1] > 1) {
						int count = 2;
						int index1 = 0;
						int index2 = 0;
						for (int i = s.length() - 1; i >= 0; i--) {
							if (s.charAt(i) == '1') {
								--count;
								if (count == 0) {
									index2 = i;
									break;
								} else
									index1 = i;
							}
						}
						StringBuilder sb = new StringBuilder(s);
						sb.deleteCharAt(index1);
						sb.deleteCharAt(index2);
	
						if (index2 == 0) {
							ans2=remove_leadng_zeroes(0, sb.toString());
							//pw.println();
	
						}
	
					} 
				}
				if (ans.toString().equals(""))
					pw.println(-1);
				else if(ans.toString().length() > ans2.length()){
					String ansfinal=ans.toString();
					if(ans.charAt(0) =='0'){
						ansfinal=remove_leadng_zeroes(0, ansfinal);
					}
					pw.println(ansfinal);
				}
				else
					pw.println(ans2);
			}
			pw.flush();
			pw.println();
		}
	
		static String remove_leadng_zeroes(int index, String s) {// ba3d mabnmsh el
																	// index
			if (index != 0) {
				return s;
			} else {
				for (int i = 0; i < s.length(); i++) {
					if (s.charAt(i) != '0') {
						return s.substring(i);
					}
	
				}
			}
			return "0";
		}
	
		static int dp(int index, int mod) {
	
			if (index == s.length()) {
				if (mod == 0)
					return 0;
				else
					return -(int) 1e9;
			}
			if (dp[index][mod] != -1)
				return dp[index][mod];
			if (s.charAt(index) == '0') {// i will take it 3shan bwrong
				return dp[index][mod] = dp(index + 1, mod);
			}
			int taken = dp(index + 1, (mod + (s.charAt(index) - '0') % 3) % 3);
			int notTaken = dp(index + 1, mod);
			return dp[index][mod] = Math.max(taken, notTaken);
	
		}
	
		static StringBuilder ans = new StringBuilder();
	
		static void Print(int i, int j) {
			if (i == s.length())
				return;
			int optimal = dp(i, j);
			int sol1 = dp(i + 1, (j + (s.charAt(i) - '0') % 3) % 3);
			int sol2 = dp(i + 1, j);
			if (s.charAt(i) == '0') {
				ans.append(s.charAt(i));
				Print(i + 1, j);
			} else if (optimal == sol1) {
				ans.append(s.charAt(i));
				Print(i + 1, (j + (s.charAt(i) - '0') % 3) % 3);
			} else if (optimal == sol2)
				Print(i + 1, j);
	
		}
	}