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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] a;
        int n;

        String[] calc(String number) {
            int n = number.length();
            for (int i = 0; i < n; ++i) {
                a[i] = number.charAt(i) - '0';
            }
            String[] dp = new String[3];
            String[] st = new String[4];
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < 4; ++j) st[j] = null;
                for (int j = 0; j < 3; ++j)
                    if (dp[j] != null) {
                        st[(j + a[i]) % 3] = dp[j] + number.charAt(i);
                    }
                for (int j = 0; j < 3; ++j)
                    if (st[j] != null) {
                        if (dp[j] == null || dp[j].length() >= st[j].length()) dp[j] = st[j];
                    }
                if (dp[a[i] % 3] == null || dp[a[i] % 3].length() >= 1) dp[a[i] % 3] = "" + number.charAt(i);
            }
            return dp;
        }

        public void output(PrintWriter out, String ret) {
            out.println(ret);
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String number = in.nextToken();
            n = number.length();
            a = new int[n];
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                a[i] = number.charAt(i) - '0';
                sum += a[i];
                sum %= 3;

            }
            if (sum == 0) {
                //out.println(number);
                output(out, number);
                //out.println(number.length());
                return;
            }
            String[] dp = calc(number);

            if (dp[sum] == null || dp[sum].length() == number.length()) {
                out.println(-1);
                return;
            }


            String s = dp[sum];
            int id1 = s.length() - 1;

            StringBuilder sb = new StringBuilder();
            for (int i = number.length() - 1; i >= 0; --i) {
                if (id1 >= 0 && s.charAt(id1) == number.charAt(i)) {
                    id1--;
                } else {
                    sb.append(number.charAt(i));
                }
            }

            sb = sb.reverse();
            int pos = 0;
            while (pos < sb.length() - 1 && sb.charAt(pos) == '0') {
                pos++;
            }
            if (pos == 0) {
                //out.println(sb.substring(pos));
                output(out, sb.substring(pos));
            } else {
                int tmp = dp[sum].length();
                String n2 = sb.substring(pos);
                dp = calc(n2);
                if (dp[sum] == null) {
                    //out.println(n2);
                    output(out, n2);
                } else {
                    if (dp[sum].length() < tmp + pos) {
                        s = dp[sum];
                        id1 = s.length() - 1;

                        sb = new StringBuilder();
                        for (int i = number.length() - 1; i >= 0; --i) {
                            if (id1 >= 0 && s.charAt(id1) == number.charAt(i)) {
                                id1--;
                            } else {
                                sb.append(number.charAt(i));
                            }
                        }

                        sb = sb.reverse();
                        pos = 0;
                        while (pos < sb.length() - 1 && sb.charAt(pos) == '0') {
                            pos++;
                        }
                        //out.println(sb.substring(pos));
                        output(out, sb.substring(pos));
                    } else {
                        output(out, n2);
                    }
                }
            }

            //out.println(sb.substring(pos).length());
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextToken() {
            int c;
            while (isSpaceChar(c = read())) ;
            StringBuilder result = new StringBuilder();
            result.appendCodePoint(c);
            while (!isSpaceChar(c = read()))
                result.appendCodePoint(c);
            return result.toString();
        }

        public static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}