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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/**
 * Created by Lenovo on 06-12-2016.
 */
public class c {
     public static void main(String args[]) throws IOException {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         PrintWriter pw = new PrintWriter(System.out);
         String s=br.readLine();
         boolean lead=true;
         int sum=0;
         int num=0;
         int ans=0;
         int arr[]=new int[2];
         if(s.length()==1){
             int g=Integer.parseInt(s);
             if(g%3!=0){
                 System.out.println("-1");
             }
             else {
                 System.out.println(s);
             }
             return;
         }
         else if(s.length()==2){
             int g1=Integer.parseInt(s.substring(0,1));
             int g2=Integer.parseInt(s.substring(1,2));
             if(g1==0&&g2==0){
                 System.out.println("0");
             }
             else if(g1%3==0&&g2%3==0){
                 System.out.println(s);
             }
             else if((g1+g2)%3==0){
                 System.out.println(s);
             }
             else if(g1%3!=0&&g2%3==0){
                 System.out.println(g2);
             }
             else if(g1%3==0&&g2%3!=0){
                 System.out.println(g1);
             }
             else{
                 System.out.println("-1");
             }
             return;
         }
         for(int i=0;i<s.length();i++){
             if(s.charAt(i)==0&&lead){
                 ans++;
             }
             else {
                 lead=false;
                 int g=Integer.parseInt(s.substring(i,i+1));
                 sum+=g;
                 sum%=3;
                 num++;
                 if(g%3==1){
                     arr[0]++;
                 }
                 else if(g%3==2){
                     arr[1]++;
                 }
             }
         }
         s=s.substring(ans,s.length());
         if(sum%3==0){
             System.out.println(s);
         }
         else if(sum%3==1){
             if(arr[0]==0&&arr[1]<2){
                 System.out.println("-1");
                 return;
             }
             int num2=-1;
             int num1=-1;
             int b1=-1;
             int b2=-1;
             int b3=-1;
             int ans1=0;
             for(int i=s.length()-1;i>=0;i--){
                 int g=Integer.parseInt(s.substring(i,i+1));
                 if(g%3!=2) {
                     if (num1 != -1 && num2 != -1) {
                         if (s.charAt(i) != '0') {
                             b1 = i;
                         }
                     } else if (num2 == -1) {
                         if (g > 0) {
                             b3 = i;
                         }
                     } else if (num1 == -1) {
                          if (g > 0) {
                             b2 = i;
                         }
                     }
                 }
                 else{
                     if(num1!=-1&&num2!=-1){
                         if(s.charAt(i)!='0')
                         b1=i;
                     }
                     else if (num2 == -1){
                         num2=i;
                     }
                     else if(num1==-1){
                         num1=i;
                     }
                 }
             }
             String s1="";
             if(num1==-1){
                 ans1=Integer.MAX_VALUE;
                 s1="-1";
             }
             else{
                 if(b1<0&&b2<0&&b3<0){
                     ans1=s.length()-1;
                     s1="0";
                 }
                 else if(b1>=0){
                     ans1=2+b1;
                     s1=s.substring(b1,num1);
                     s1+=s.substring(num1+1,num2);
                     s1+=s.substring(num2+1,s.length());
                 }
                 else if(b2>=0){
                     ans1=b2+1;
                     s1=s.substring(b2,num2);
                     s1+=s.substring(num2+1,s.length());
                 }
                 else if(b3>=0){
                     ans1=b3;
                     s1=s.substring(b3,s.length());
                 }
             }
             int p1=-1;
             int p2=-1;
             int p=-1;
             int ans2=0;
             String s2="";
             for(int i=s.length()-1;i>=0;i--) {
                 int g = Integer.parseInt(s.substring(i, i + 1));
                 if (g % 3 != 1) {
                     if (p == -1) {
                         if (g > 0) {
                             p2 = i;
                         }
                     } else if (p > -1) {

                         if (g > 0) {
                             p1 = i;
                         }
                     }
                 }
                 else{
                     if(p==-1){
                         p=i;
                     }
                     else{
                         p1=i;
                     }
                 }

             }
             if(p<0){
                 ans2=Integer.MAX_VALUE;
                 s2="-1";
             }
             else if(p1<0&&p2<0){
                 ans2=s.length()-1;
                 s2="0";
             }
             else if(p1>=0){
                 ans2=p1+1;
                 s2=s.substring(p1,p);
                 s2+=s.substring(p+1,s.length());
             }
             else if(p2>=0){
                 ans2 =p2;
                 s2=s.substring(p2,s.length());
             }
             if(ans1<=ans2){
                 System.out.println(s1);
             }
             else {
                 System.out.println(s2);
             }

         }
         else{
             if(arr[1]==0&&arr[0]<2){
                 System.out.println("-1");
                 return;
             }
             int num2=-1;
             int num1=-1;
             int b1=-1;
             int b2=-1;
             int b3=-1;
             int ans1=0;
             for(int i=s.length()-1;i>=0;i--){
                 int g=Integer.parseInt(s.substring(i,i+1));
                 if(g%3!=1) {
                     if (num1 != -1 && num2 != -1) {
                         if (s.charAt(i) != '0') {
                             b1 = i;
                         }
                     } else if (num2 == -1) {
                         if (g > 0) {
                             b3 = i;
                         }
                     } else if (num1 == -1) {
                         if (g > 0) {
                             b2 = i;
                         }
                     }
                 }
                 else{
                     if(num1!=-1&&num2!=-1){
                         if(s.charAt(i)!='0')
                             b1=i;
                     }
                     else if (num2 == -1){
                         num2=i;
                     }
                     else if(num1==-1){
                         num1=i;
                     }
                 }
             }
             String s1="";
             if(num1==-1){
                 ans1=Integer.MAX_VALUE;
                 s1="-1";
             }
             else{
                 if(b1<0&&b2<0&&b3<0){
                     ans1=s.length()-1;
                     s1="0";
                 }
                 else if(b1>=0){
                     ans1=2+b1;
                     s1=s.substring(b1,num1);
                     s1+=s.substring(num1+1,num2);
                     s1+=s.substring(num2+1,s.length());
                 }
                 else if(b2>=0){
                     ans1=b2+1;
                     s1=s.substring(b2,num2);
                     s1+=s.substring(num2+1,s.length());
                 }
                 else if(b3>=0){
                     ans1=b3;
                     s1=s.substring(b3,s.length());
                 }
             }
             int p1=-1;
             int p2=-1;
             int p=-1;
             int ans2=0;
             String s2="";
             for(int i=s.length()-1;i>=0;i--) {
                 int g = Integer.parseInt(s.substring(i, i + 1));
                 if (g % 3 != 2) {
                     if (p == -1) {
                         if (g > 0) {
                             p2 = i;
                         }
                     } else if (p > -1) {

                         if (g > 0) {
                             p1 = i;
                         }
                     }
                 }
                 else{
                     if(p==-1){
                         p=i;
                     }
                     else{
                         p1=i;
                     }
                 }

             }
             if(p<0){
                 ans2=Integer.MAX_VALUE;
                 s2="-1";
             }
             else if(p1<0&&p2<0){
                 ans2=s.length()-1;
                 s2="0";
             }
             else if(p1>=0){
                 ans2=p1+1;
                 s2=s.substring(p1,p);
                 s2+=s.substring(p+1,s.length());
             }
             else if(p2>=0){
                 ans2 =p2;
                 s2=s.substring(p2,s.length());
             }
             if(ans1<=ans2){
                 System.out.println(s1);
             }
             else {
                 System.out.println(s2);
             }
         }

     }

    public static int bs(String s,int k,int low,int high){
        int count=0; int curr=1;
        //System.out.println(low);
       // System.out.println(high);
        if(low>=high){
            return low;
        }
        else{int gg=(low +high)/2;

            for(int i=1;i<s.length();i++){
                if(s.charAt(i)==s.charAt(i-1)){
                    curr++;
                }
                else{
                    count+=curr/(gg+1);
                    curr=1;
                }
            }
            count+=curr/(gg+1);
          // System.out.println(count+"  count");
            if(count <=k){
                return(bs(s,k,low,gg));
            }
            else{

                return(bs(s,k,gg+1,high));

            }
        }
    }

}