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.*;
import java.math.*;
public class code1 {
	InputStream is;
	PrintWriter out;
	void solve()
	{
		String s=ns();
		ArrayList<Integer> zero=new ArrayList<Integer>();
		ArrayList<Integer> one=new ArrayList<Integer>();
		ArrayList<Integer> two=new ArrayList<Integer>();
		int sum=0,fzero=0;
		if(s.length()==1)
		{
			if((s.charAt(0)-'0')%3==0)
				out.print(s);
			else
				out.print(-1);
			return;
		}
		for(int i=0;i<s.length();i++)
		{
			sum+=s.charAt(i)-'0';
			if(s.charAt(i)=='0')
				fzero=1;
			int rem=(s.charAt(i)-'0')%3;
			if(rem==0)
				zero.add(i);
			else if(rem==1)
				one.add(i);
			else
				two.add(i);
		}
		StringBuffer sb=new StringBuffer(s);
		int flag=0;
		if(sum%3==0)
		{
			out.println(s);
			return;
		}
		else if(sum%3==1)
		{
			if(one.size()!=0)
			{
				int last=one.get(one.size()-1);
				if(last==0)
				{
					int count=1;
					for(int i=1;i<s.length();i++)
					{
						if(s.charAt(i)=='0')
							count++;
						else
							break;
					}
					if(two.size()>=2&&count>=2)
					{
						sb.replace(two.get(0),two.get(0)+1,"-");
						sb.replace(two.get(1),two.get(1)+1,"-");
					}
					else
					{
						for(int i=0;i<count;i++)
							sb.replace(i,i+1,"-");
					}
				}
				else
				{
					sb.replace(last,last+1,"-");
				}
			}
			else if(two.size()>=2&&s.length()!=2)
			{
				int last=two.get(two.size()-1);
				int secondlast=two.get(two.size()-2);
				if(secondlast==0)
				{
					sb.replace(last,last+1,"-");
					sb.replace(secondlast,secondlast+1,"-");
					int state=0;
					for(int i=1;i<last;i++)
					{
						if(s.charAt(i)=='0')
							sb.replace(i,i+1,"-");
						else
						{
							state=1;
							break;
						}
					}
					if(state==0)
					{
						for(int i=last+1;i<s.length();i++)
						{
							if(s.charAt(i)=='0')
								sb.replace(i,i+1,"-");
							else
							{
								break;
							}
						}
					}
					
				}
				else
				{
					sb.replace(last,last+1,"-");
					sb.replace(secondlast,secondlast+1,"-");
					
				}
			}
			else
				flag=1;
		}
		else
		{

			if(two.size()!=0)
			{
				int last=two.get(two.size()-1);
				if(last==0)
				{
					int count=1;
					for(int i=1;i<s.length();i++)
					{
						if(s.charAt(i)=='0')
							count++;
						else
							break;
					}
					if(one.size()>=2&&count>=2)
					{
						sb.replace(one.get(0),one.get(0)+1,"-");
						sb.replace(one.get(1),one.get(1)+1,"-");
					}
					else
					{
						for(int i=0;i<count;i++)
							sb.replace(i,i+1,"-");
					}
				}
				else
				{
					sb.replace(last,last+1,"-");
				}
			}
			else if(one.size()>=2&&s.length()!=2)
			{
				int last=one.get(one.size()-1);
				int secondlast=one.get(one.size()-2);
				if(secondlast==0)
				{
					sb.replace(last,last+1,"-");
					sb.replace(secondlast,secondlast+1,"-");
					int state=0;
					for(int i=1;i<last;i++)
					{
						if(s.charAt(i)=='0')
							sb.replace(i,i+1,"-");
						else
						{
							state=1;
							break;
						}
					}
					if(state==0)
					{
						for(int i=last+1;i<s.length();i++)
						{
							if(s.charAt(i)=='0')
								sb.replace(i,i+1,"-");
							else
							{
								break;
							}
						}
					}
					
				}
				else
				{
					sb.replace(last,last+1,"-");
					sb.replace(secondlast,secondlast+1,"-");
					
				}
			}
			else
				flag=1;
			
		}
		if(flag==1)
		{
			if(fzero==0)
				out.println(-1);
			else
				out.println(0);
		}
		else
		{
			int ss=0;
			for(int i=0;i<sb.length();i++)
			{
				if(sb.charAt(i)!='-')
				{
					ss=1;
					out.print(sb.charAt(i));
				}
			}
			if(ss==0)
			{
				if(fzero==0)
					out.print(-1);
				else
					out.print(0);
			}
		}
	}
	 static class Pair implements Comparable<Pair>{
		 
	        int x,y,k,i;
	        
		Pair (int x,int y,int i){
			this.x=x;
			this.y=y;
			this.i=i;
		}
	        
		public int compareTo(Pair o) {
					if(this.i!=o.i)
						return Long.compare(this.i,o.i);
					else 
						return Long.compare(this.x,o.x);
		}
	 
	        public boolean equals(Object o) {
	            if (o instanceof Pair) {
	                Pair p = (Pair)o;
	                return p.x == x && p.y == y && p.k==k;
	            }
	            return false;
	        }
	           
	 
	        @Override
	        public String toString() {
	            return  "("+x + " " + y +" "+k+" "+i+" )";
	        }
	    
	    } 
	    
	    public static boolean isPal(String s){
	        for(int i=0, j=s.length()-1;i<=j;i++,j--){
	                if(s.charAt(i)!=s.charAt(j)) return false;
	        }
	        return true;
	    }
	    public static String rev(String s){
			StringBuilder sb=new StringBuilder(s);
			sb.reverse();
			return sb.toString();
	    }
	    
	    public static long gcd(long x,long y){
		if(x%y==0)
			return y;
		else
			return gcd(y,x%y);
	    }
	    
	    public static int gcd(int x,int y){
		if(x%y==0)
			return y;
		else 
			return gcd(y,x%y);
	    }
	    
	    public static long gcdExtended(long a,long b,long[] x){
	        
	        if(a==0){
	            x[0]=0;
	            x[1]=1;
	            return b;
	        }
	        long[] y=new long[2];
	        long gcd=gcdExtended(b%a, a, y);
	        
	        x[0]=y[1]-(b/a)*y[0];
	        x[1]=y[0];
	        
	        return gcd;
	    }
	    
	    public static int abs(int a,int b){
		return (int)Math.abs(a-b);
	    }
	 
	    public static long abs(long a,long b){
		return (long)Math.abs(a-b);
	    }
	    
	    public static int max(int a,int b){
		if(a>b)
			return a;
		else
			return b;
	    }
	 
	    public static int min(int a,int b){
		if(a>b)
			return b;
		else 
			return a;
	    }
	    
	    public static long max(long a,long b){
		if(a>b)
			return a;
		else
			return b;
	    }
	 
	    public static long min(long a,long b){
		if(a>b)
			return b;
		else 
			return a;
	    }
	 
	    public static long pow(long n,long p,long m){
		 long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    if(result>=m)
		    result%=m;
		    p >>=1;
		    n*=n;
		    if(n>=m)
		    n%=m;
		}
		return result;
	    }
	    
	    public static long pow(long n,long p){
		long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;	    
		    p >>=1;
		    n*=n;	    
		}
		return result;
	    }
	    public static void debug(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}
	    void run() throws Exception {
			is = System.in;
			out = new PrintWriter(System.out);
			solve();
			out.flush();
		}
	   
	    public static void main(String[] args) throws Exception {
			new code1().run();
		}

	    private byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;
	 
		private int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}
	 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
	 
		private int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}
	 
		private double nd() {
			return Double.parseDouble(ns());
		}
	 
		private char nc() {
			return (char) skip();
		}
	 
		private String ns() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
	 
		private char[] ns(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}
	 
		private char[][] nm(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = ns(m);
			return map;
		}
	 
		private int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = ni();
			return a;
		}
	 
		private int ni() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}
	 
			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	 
		private long nl() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}
	 
			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	 
}