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.awt.*;
import java.io.*;

import java.math.BigInteger;
import java.util.*;

public class TaskC {


    static Integer[][] memo;
    static int[] arr;
    static int n, OO = (int) 1e9;


    static int dp(int mod, int idx , boolean isTake)
    {
        if (idx == n ) return mod == 0? 0 : OO;
        if(memo[mod][idx] != null) return memo[mod][idx];

        int leave = OO;
        int remove = OO;

        if(arr[idx] != 0) {
            leave = dp((mod + arr[idx]) % 3, idx + 1, true);
            remove = 1 + dp(mod, idx + 1, isTake);
        }else
        {
            if(isTake)
                leave = dp(mod , idx + 1, true);
            else
                remove = 1 + dp(mod, idx + 1, isTake);

        }
        return memo[mod][idx] = Math.min(remove , leave);
    }

    static boolean f = false;
    static StringBuilder ans = new StringBuilder();

    public static void print(int mod , int idx , boolean isTake) {
        if (idx == n) return;

        int op = memo[mod][idx];
        int remove = 1 + dp(mod, idx + 1, isTake);
        int leave = dp((mod + arr[idx]) % 3, idx + 1, true);

        if(arr[idx] != 0)
        {
            if(op == remove)
                print( mod, idx + 1, isTake);
            else
            {
                f = true;
                ans.append(arr[idx]);
                print((mod + arr[idx]) % 3, idx + 1, true);
            }

        }
        else
        {
            if(isTake)
            {
                f = true;
                ans.append(arr[idx]);
                print((mod + arr[idx]) % 3, idx + 1, true);
            }else
                print(mod , idx+ 1 ,isTake);
        }

    }


    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        String s = sc.nextLine();
        n = s.length();
        arr = new int[n];

        boolean isZero = false;
        for (int i = 0 ; i < n ; i++) {
            arr[i] = Integer.parseInt("" + s.charAt(i));
            isZero|=arr[i] == 0;
        }
        memo = new Integer[4][n + 1];
        dp(0 , 0 , false);
        print(0 , 0 ,false);
        int i = 0;

        if(!f)
            pw.println(isZero ? 0:-1);
        else
        {
            boolean k = false;
            for (i = 0 ; i < ans.length() ; i++)
            {
                if(ans.charAt(i) == '0' && !k)
                {
                    continue;
                }else
                {
                    k = true;
                    pw.print(ans.charAt(i));
                }
            }
            if(!k)
                pw.print(0);
        }
        pw.close();
    }
    static class Point implements Comparable<Point>
    {
        int x ,y ;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(Point o) {
            if (x == o.x) {
                return y - o.y;
            }
            return x - o.x;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }

    static class Circle implements Comparable<Circle>
    {
        int x , radius ,idx;
        public Circle(int x , int r , int idx)
        {
            this.x = x;
            this.radius = r;
            this.idx = idx;
        }

        public boolean isInside(Point p)
        {
            return (p.x - x)*(p.x - x) + (p.y)*(p.y) <= radius * radius;
        }

        @Override
        public String toString() {
            return "Circle{" +
                    "x=" + x +
                    ", radius=" + radius +
                    '}';
        }

        @Override
        public int compareTo(Circle o) {
            return x - o.x;
        }
    }

    private static long gcd(long a, long b) {
        if( b == 0)
            return a;
        return gcd(b  , a%b);
    }

    static long lcm(int a, int b)
    {
        return (a*b)/gcd(a, b);
    }


    private  static int dis(int xa , int ya , int xb , int yb)
    {
        return (xa-xb)*(xa - xb) + (ya- yb)*(ya-yb);
    }


    static class Pair implements Comparable<Pair> {
        int x,y;


        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int compareTo(Pair o) {
            if (y  == o.y)
                return x - o.x;
            return y - o.y;

        }

        public double dis(Pair a){

            return (a.x - x)*(a.x - x) + (a.y-y)*(a.y-y);
        }

        public String toString() {
            return  x+" "+ y;
        }
        public boolean overlap(Pair a)
        {
            if((this.x >= a.x && this.x <= a.y) || (a.x >= this.x && a.x <= this.y)) return true;
            return false;

        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public boolean check() {
            if (!st.hasMoreTokens())
                return false;
            return true;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        public double nextDouble() {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() {
            try {
                return br.ready();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}