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.io.*;
import java.util.*;
import java.awt.*;
public class edu18Cnew
{
	BufferedReader in;
	PrintWriter ob;
	StringTokenizer st;
	ArrayList<Integer> gr[];
	public static void main(String[] args) throws IOException {
		new edu18Cnew().run();
	}
	void run() throws IOException {
		in=new BufferedReader(new InputStreamReader(System.in));
		ob=new PrintWriter(System.out);
		solve();
		ob.flush();
	}
	@SuppressWarnings("unchecked")
	void solve() throws IOException {
		char s[] = ns().toCharArray();
		int j = 0;
		while(j<s.length && s[j]=='0') 
			++j;
		//s=new String(s).substring(j).toCharArray();
		if(j>0)
		{
				int  length = s.length - j , k=0; 
				char t [] =new char[length];
				for(int i= j ; i<s.length ; i++)
						t[k++] = s[i]; 
				s=t;
		}
		
		if(s.length==0) {
			ob.println("0");
			return;
		}

		long sum = 0;
		for(int i=0 ; i<s.length ; i++) 
			sum += (s[i]-'0');

		{
			gr=new ArrayList[10];
			for (int i=0 ; i<=9 ; i++ ) 
				gr[i] = new ArrayList<Integer>();

			for (int i=0 ; i<s.length ; i++ ) {
				if(gr[s[i]-'0'].size()<=9)
				gr[s[i]-'0'].add(i);
			}

		}
		
		//ob.println(sum);
		int index = 0;
		Point p = new Point(-1,-1);
		int len = s.length;
		if(sum%3==0) {
			ob.println(s);
			return;
		}
		else if(sum%3==1) {
			int start = 1;
			String temp = "";
			int maxlen = -1 ;
			String res = "";
			int f = 0;
			while(start<=16) {
				for(int x=0 ; x<=9 ; x++) {
					for(int y=1 ; y<=9 ; y++) {
						index = -1;
						p = new Point(-1,-1);
						if(x+y==start) {
							if(x==0) {
								index = getIndex( y , s );
							}
							else
								p = getIndex(x, y , s);
						}
						if(index!=-1)  {
							temp = getString( index , s  );
							int l = temp.length();
							if(l>maxlen) {
								maxlen = l;
								res = temp;			
							}
						}
						if(p.x!=-1 && p.y!=-1)  {
							temp = getString( p.x , p.y , s ) ;
							int l = temp.length();
							if(l>maxlen) {
								maxlen = l;
								res = temp;			
							}
						}
						if(len-maxlen<=1) {f=1;break;}
						if(len-maxlen==2 && x>0) {f=1;break;}
							
					}
					if(len-maxlen<=1) {f=1;break;}
					if(len-maxlen==2 && x>0) {f=1;break;}
				}
				if(f==1) break;
				
				start+=3;
			}
			if(maxlen<=0) {
				ob.println("-1");
			}
			else
				ob.println(res);
		}
		else if(sum%3==2) {
			//ArrayList<String> list = new ArrayList<String>();
			int start = 2;
			String temp = "";
			int maxlen = -1 ;
			String res = "";
			int f=0;
			while(start<=17) {
			for(int x=0 ; x<=9 ; x++) {
					for(int y=1 ; y<=9 ; y++) {
						index = -1;
						p = new Point(-1,-1);
						if(x+y==start) {
							if(x==0) {
								index = getIndex( y , s );
							}
							else
								p = getIndex(x, y , s);
						}
						if(index!=-1)  {
							temp = getString( index , s  );
							int l = temp.length();
							if(l>maxlen) {
								maxlen = l;
								res = temp;			
							}
						}
						if(p.x!=-1 && p.y!=-1)  {
							temp = getString( p.x , p.y , s ) ;
							int l = temp.length();
							if(l>maxlen) {
								maxlen = l;
								res = temp;			
							}
						}
						if(len-maxlen<=1) {f=1;break;}
						if(len-maxlen==2 && x>0) {f=1;break;}
							
					}
					if(len-maxlen<=1) {f=1;break;}
					if(len-maxlen==2 && x>0) {f=1;break;}
				}
				if(f==1) break;
				
				start+=3;
			}
			if(maxlen<=0) {
				ob.println("-1");
			}
			else
				ob.println(res);
			}
		}
	
	String getString(int i , int j , char s[]) {
		StringBuffer ans = new StringBuffer("");
		for(int x=0 ; x<s.length ; x++) {
			if(x==i || x==j) continue;
			else
				 ans.append(s[x]);
		}
		if(ans.length()==0) {
			return "";
		}
		else if(ans.charAt(0)!='0')
			return new String(ans);
		else {
			int f=0;
			while(f<ans.length() && ans.charAt(f)=='0') {
				++f;
			}	
			String ans1 = new String(ans).substring(f);
			if(ans1.length()==0) 
				return "0";
			else
				return ans1;
		}
	}

	String getString(int i , char s[]) {
		StringBuffer ans = new StringBuffer(new String(s));
		ans.delete(i , i+1);
		
		if(ans.length()==0) {
			return "";
		}
		else if(ans.charAt(0)!='0')
			return new String(ans);
		else {
			int f=0;
			while(f<ans.length() && ans.charAt(f)=='0') {
				++f;
			}	
			String ans1 = new String(ans).substring(f);
			if(ans1.length()==0) 
				return "0";
			else
				return ans1;
		}
	}

	int getIndex(int y , char s[]) {
		if(gr[y].size()>0) {
			return gr[y].get(gr[y].size()-1);
		}
		return -1;
	}

	Point getIndex(int x , int y , char s[]) {
		if(x==y && gr[x].size()>=2) {
			Point p = new Point();
			p.x = gr[x].get(gr[x].size()-1);
			p.y = gr[y].get(gr[y].size()-2);
			return p;
		}
		else if(x!=y  && gr[y].size()>0 && gr[x].size()>0) {
			Point p = new Point();
			p.x = gr[x].get(gr[x].size()-1);
			p.y = gr[y].get(gr[y].size()-1);
			return p;
		}
		return new Point(-1,-1);
	}
	
	String ns() throws IOException {
		return nextToken();
	}
	int[] nia(int start,int b) throws IOException {
		int a[]=new int[b];
		for(int i=start;i<b;i++)
			a[i]=ni();
		return a;
	}
	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}
	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}
	String nextToken() throws IOException {
		if(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(in.readLine());
		return st.nextToken();
	}
}