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.*;
 
public class Main {
	static int t,n,m,k,mod=998244353,maxn=300005;
    static long INF=(long)1e16;
    
    void solve(PrintWriter out, Reader in) throws IOException{
        String str = in.next();
        n = str.length();
        
        int cur = -1,max=0;
        int[][] ss = new int[2][3];
        int[][] par = new int[n][3];
        int[][] dp = new int[n][3];
        if(str.charAt(0)!='0') dp[0][(str.charAt(0)-'0')%3] = 1;
        
        if(dp[0][0]==1) {cur=0;max=1;par[0][0]=-1;}
        
        boolean flag = false;
        if(str.charAt(0)=='0') flag = true;
        
        int tmp=0;
        for(int i=1;i<n;i++){
            if(str.charAt(i)=='0') flag=true;
            for(int j=0;j<3;j++){
                if(dp[i-1][j]==0) continue;
                
                tmp = (j+str.charAt(i)-'0')%3;
                if(dp[i-1][j]+1>dp[i-1][tmp]) {
                    dp[i][tmp] = dp[i-1][j]+1;
                    par[i][tmp] = ss[0][j];
                    ss[1][tmp] = i;
                }else{
                    dp[i][tmp] = dp[i-1][tmp];
                }
            }
            for(int j=0;j<3;j++) dp[i][j] = Math.max(dp[i-1][j],dp[i][j]);
            if(dp[i][0]>max) {cur=i;max=dp[i][0];}
            
            //out.println(dp[i][0]);
            tmp = (str.charAt(i)-'0')%3;
            if(str.charAt(i)!='0' && dp[i][tmp]==0){
                dp[i][tmp] = 1;
                par[i][tmp] = -1;
                ss[1][tmp] = i;
                if(tmp==0){
                    max = 1;
                    cur = i;
                }
            }
            for(int j=0;j<3;j++) ss[0][j] = Math.max(ss[0][j],ss[1][j]);
        }
        
        int sum=0;
        if(max==0 && !flag){
            out.println(-1);
        }else if(flag && max<=1){
            out.println('0');
        }else{
            Stack<Integer> st = new Stack<Integer>();
            st.add(str.charAt(cur)-'0');
            tmp = cur;
            
            cur = par[cur][sum];
            sum = (sum-(str.charAt(tmp)-'0')+9)%3;
            for(int i=1;i<max;i++){
                
                st.add(str.charAt(cur)-'0');
                tmp = cur;
                cur = par[cur][sum];
                sum = (sum-(str.charAt(tmp)-'0')+9)%3;
            }
            
            while(st.size()!=0) out.print(st.pop());
            out.println();
        }
        
    }
    
    
    static class Reader {
 
    private InputStream mIs;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
 
    public Reader() {
        this(System.in);
    }
 
    public Reader(InputStream is) {
        mIs = is;
    }
 
    public int read() {
        if (numChars == -1) {
            throw new InputMismatchException();
 
    }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = mIs.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }
 
    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }
 
    public String next() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
 
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
 
    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
 
    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
 
    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
 
    public boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }
 
    }
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();
 
    }
}