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 java.io.*;
		
		public class codeforces
		{	
			public static void main(String[] args)
			{
				InputReader in = new InputReader(System.in);
				PrintWriter pw = new PrintWriter(System.out);
				
				String s = in.nextLine();
				int n = s.length();
				int[] a = new int[n];
				int[] index = new int[2];
				boolean[] flag = new boolean[n];
				int sum = 0, r1 = 0, r2 = 0, x = -1, zero = -1;
				
				for(int i=0;i<n;i++)
					a[i] = s.charAt(i) - '0';
				
				for(int i=0;i<n;i++)
					sum += a[i];
				
				Arrays.fill(index, -1);
				Arrays.fill(flag, true);
				
				if(sum%3==1)
				{
					for(int i=n-1;i>=0;i--)
					{
						if(a[i]%3 == 1)
						{
							x = i;
							break;
						}
					}
					
					for(int i=n-1;i>=0;i--)
					{
						if(a[i] == 0)
							zero = i;
						
						if(a[i]%3 == 2)
						{
							if(r2<2)
							{
								index[r2] = i;
								r2++;
							}
						}
					}
				}
				else if(sum%3==2)
				{
					for(int i=n-1;i>=0;i--)
					{
						if(a[i]%3 == 2)
						{
							x = i;
							break;
						}
					}
					
					for(int i=n-1;i>=0;i--)
					{
						if(a[i]%3 == 1)
						{
							if(r2<2)
							{
								index[r2] = i;
								r2++;
							}
						}
					}
				}
				
				if(x==-1)
				{
					for(int i=0;i<2;i++)
					{
						if(index[i] != -1)
							flag[index[i]] = false;
					}
				}
				else if(index[0] == -1 || index[1] == -1)
				{
					if(x != -1)
						flag[x] = false;
				}
				else
				{
					if(x==0 && n>1 && a[1]==0)
					{
						flag[index[0]] = false;
						flag[index[1]] = false;
					}
					else
					{
						flag[x] = false;
					}
				}
				
				for(int i=0;i<n;i++)
				{
					if(a[i]!=0 && flag[i])
						break;
					else
					{
						if(a[i] == 0)
							flag[i] = false;
					}
				}
				
				for(int i=0;i<n;i++)
				{
					if(!flag[i])
						r1++;
				}
				
				if(r1 == n)
				{
					for(int i=0;i<n;i++)
					{
						if(a[i] == 0)
						{
							flag[i] = true;
							r1--;
							break;
						}
					}
				}
				
				if(r1 == n)
					pw.println(-1);
				else
				{
					for(int i=0;i<n;i++)
					{
						if(flag[i])
							pw.print(a[i]);
					}
				}

				
				pw.flush();
				pw.close();
			}
			
			public static long GCD(long a,long b)
			{
				if(b==0)
					return a;
				else
					return GCD(b,a%b);
			}
			
			static class pair implements Comparable<pair>
			{
				Long x, y;
				pair(long x,long y)
				{
					this.x=x;
					this.y=y;
				}
				
				public int compareTo(pair o) {
					int result = x.compareTo(o.x);
					if(result==0)
						result = y.compareTo(o.y);
					
					return result;
				}  
				
				public String toString()
				{
					return x+" "+y;
				}
				
				public boolean equals(Object o)
				{
					if (o instanceof pair)
				    {
						pair p = (pair)o;
						return p.x - x == 0 && p.y - y == 0 ;
					}
					return false;
				}
				
				public int hashCode()
				{
					return new Long(x).hashCode()*31 + new Long(y).hashCode();
				}
			}
			
			static class InputReader 
			{
				 
				private final InputStream stream;
				private final byte[] buf = new byte[8192];
				private int curChar, snumChars;
				private SpaceCharFilter filter;
		 
				public InputReader(InputStream stream) 
				{
					this.stream = stream;
				}
		 
				public int snext() 
				{
					if (snumChars == -1)
						throw new InputMismatchException();
					if (curChar >= snumChars) 
					{
						curChar = 0;
						try 
						{
							snumChars = stream.read(buf);
						} 
						catch (IOException e) 
						{
							throw new InputMismatchException();
						}
						if (snumChars <= 0)
							return -1;
					}
					return buf[curChar++];
				}
		 
				public int nextInt() 
			    {
					int c = snext();
					while (isSpaceChar(c)) 
					{
						c = snext();
					}
					int sgn = 1;
					if (c == '-')
				    {
						sgn = -1;
						c = snext();
					}
					int res = 0;
					do 
					{
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = snext();
					} while (!isSpaceChar(c));
					return res * sgn;
				}
		 
				public long nextLong()
			    {
					int c = snext();
					while (isSpaceChar(c)) 
					{
						c = snext();
					}
					int sgn = 1;
					if (c == '-') 
					{
						sgn = -1;
						c = snext();
					}
					long res = 0;
					do 
					{
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = snext();
					} while (!isSpaceChar(c));
					return res * sgn;
				}
		 
				public int[] nextIntArray(int n) 
				{
					int a[] = new int[n];
					for (int i = 0; i < n; i++) 
					{
						a[i] = nextInt();
					}
					return a;
				}
		 
				public String readString()
			    {
					int c = snext();
					while (isSpaceChar(c)) 
					{
						c = snext();
					}
					StringBuilder res = new StringBuilder();
					do 
					{
						res.appendCodePoint(c);
						c = snext();
					} while (!isSpaceChar(c));
					return res.toString();
				}
		 
				public String nextLine() 
				{
					int c = snext();
					while (isSpaceChar(c))
						c = snext();
					StringBuilder res = new StringBuilder();
					do 
					{
						res.appendCodePoint(c);
						c = snext();
					} while (!isEndOfLine(c));
					return res.toString();
				}
		 
				public boolean isSpaceChar(int c) 
				{
					if (filter != null)
						return filter.isSpaceChar(c);
					return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				}
		 
				private boolean isEndOfLine(int c) 
				{
					return c == '\n' || c == '\r' || c == -1;
				}
		 
				public interface SpaceCharFilter
			    {
					public boolean isSpaceChar(int ch);
				}
			}
			
			static class CodeX {
	        public static void sort(long arr[]) {
	            merge_sort(arr, 0, arr.length - 1);
	        }
	
	        private static void merge_sort(long A[], long start, long end) {
	            if (start < end) {
	                long mid = (start + end) / 2;
	                merge_sort(A, start, mid);
	                merge_sort(A, mid + 1, end);
	                merge(A, start, mid, end);
	            }
	
	        }
	
	        private static void merge(long A[], long start,long mid, long end) {
	            long p = start, q = mid + 1;
	            long Arr[] = new long[(int)(end - start + 1)];
	            long k = 0;
	
	            for (int i = (int)start; i <= end; i++) {
	                if (p > mid)
	                    Arr[(int)k++] = A[(int)q++];
	
	                else if (q > end)
	                    Arr[(int)k++] = A[(int)p++];
	
	                else if (A[(int)p] < A[(int)q])
	                    Arr[(int)k++] = A[(int)p++];
	
	                else
	                    Arr[(int)k++] = A[(int)q++];
	            }
	            for (int i = 0; i < k; i++) {
	                A[(int)start++] = Arr[i];
	            }
	
	        }
	
	    }
		}