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.
// Main Code at the Bottom
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger; 
public class Main {
	//Fast IO class
    static class FastReader {
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader() {
        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
        	if(!env) {
        		try {
					br=new BufferedReader(new FileReader("src\\input.txt"));
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				}
        	}
        	else br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) {
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
        int nextInt() {
            return Integer.parseInt(next()); 
        } 
        long nextLong() {
            return Long.parseLong(next()); 
        } 
        double nextDouble() {
            return Double.parseDouble(next()); 
        } 
        String nextLine() {
            String str = ""; 
            try {
                str = br.readLine(); 
            } 
            catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }     
    static long MOD=1000000000+7;
    //Euclidean Algorithm
    static long gcd(long A,long B){
    	return (B==0)?A:gcd(B,A%B);
    }
    //Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
    //Modular Inverse
    static long inverse(long x) {
    	return fastExpo(x,MOD-2);
    }
    //Prime Number Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i*i<=n;i+=6) if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
    //Reverse an array
    static void reverse(char arr[],int l,int r){
    	while(l<r) {
    		char tmp=arr[l];
    		arr[l++]=arr[r];
    		arr[r--]=tmp;
    	}
    }
    //Print array
    static void print1d(int arr[]) {
    	out.println(Arrays.toString(arr));
    }
    static void print2d(long arr[][]) {
    	for(long a[]: arr) out.println(Arrays.toString(a));
    }
    // Pair
    static class pair{
    	int x,y;
    	pair(int a,int b){
    		this.x=a;
    		this.y=b;
    	}
    	public boolean equals(Object obj) {
    		if(obj == null || obj.getClass()!= this.getClass()) return false;
            pair p = (pair) obj;
            return (this.x==p.x && this.y==p.y);
        }
    	public int hashCode() {
            return Objects.hash(x,y);
        }
    }
    static FastReader sc=new FastReader();
    static PrintWriter out=new PrintWriter(System.out);  
    //Main function(The main code starts from here
    static String s;
    static StringBuilder f(int x) {
    	char a[]=s.substring(x).toCharArray();
    	StringBuilder sb=new StringBuilder();
    	int map[]=new int[3],sum=0,len=a.length;
    	for(int i=0;i<len;i++) {
    		sum+=a[i]-'0';
    		if(i>0)map[(a[i]-'0')%3]++;
    	}
    	sum%=3;
    	//out.println(sum);
    	if(sum==0) for(char c: a) sb.append(c);
    	else {
    		int f=0;
    		for(int i=1;i<len;i++) {
    			if((a[i]-'0')%3==sum) {
    				a[i]='x';
    				f=1;
    				break;
    			}
    		}
    		if(f==0) {
    			if(sum==1) {
    				if(map[2]>=2) {
    					int cnt=0;
    					for(int i=1;i<len;i++) {
    						if((a[i]-'0')%3==2 && cnt!=2) {
    							a[i]='x';
    							cnt++;
    						}
    					}
    				}
    				else return sb;
    			}
    			else if(sum==2) {
    				if(map[1]>=2) {
    					int cnt=0;
    					for(int i=1;i<len;i++) {
    						if((a[i]-'0')%3==1 && cnt!=2) {
    							a[i]='x';
    							cnt++;
    						}
    					}
    				}
    				else return sb;
    			}
    		}
    		for(char c: a) if(c!='x') sb.append(c);
    	}
    	return sb;
    }
    public static void main (String[] args) throws java.lang.Exception {
    	int test=1;
    	//test=sc.nextInt();
    	while(test-->0){
    		s=sc.nextLine();
    		StringBuilder sb=new StringBuilder();
    		int n=s.length(),cnt=0,max=0,z=0;
    		for(int i=0;i<n;i++) {
    			if(s.charAt(i)!='0' && cnt!=3) {
    				StringBuilder ans=f(i);
    				if(ans.length()>max) {
    					max=ans.length();
    					sb=ans;
    				}
    				cnt++;
    			}
    			if(s.charAt(i)=='0') z=1;
    		}
    		if(max!=0) out.println(sb);
    		else if(max==0 && z==1) out.println(0);
    		else out.println(-1);
    	}
        out.flush();
        out.close();
    }
}