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.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDivideByThree solver = new CDivideByThree();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDivideByThree {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            String s = in.scanString();
            int sum = 0;
            for (char c : s.toCharArray()) sum += (c - '0');
            if (sum % 3 == 0) {
                out.println(s);
                return;
            }
            if (sum % 3 == 1) {
                //remove 1
                int remove1 = Integer.MAX_VALUE;
                char[] res1 = new char[s.length()];
                int ptr1 = 0;
                boolean zeroDel1 = false;
                for (int i = s.length() - 1; i >= 0; i--) {
                    if ((s.charAt(i) - '0') % 3 == 1) {
                        remove1 = 1;
                        for (int j = 0; j < i; j++) res1[ptr1++] = s.charAt(j);
                        int j = i + 1;
                        while (i == 0 && j < s.length() && s.charAt(j) == '0') {
                            zeroDel1 = true;
                            j++;
                            remove1++;
                        }
                        while (j < s.length()) res1[ptr1++] = s.charAt(j++);
                        break;
                    }
                }
                if (ptr1 == 0 && zeroDel1) {
                    res1[ptr1++] = '0';
                    remove1--;
                }
                //remove22
                char[] res22 = new char[s.length()];
                boolean zeroDel22 = false;
                int ptr2 = 0;
                int remove22 = Integer.MAX_VALUE;
                int ct = -1;
                for (int i = s.length() - 1; i >= 0; i--) {
                    if ((s.charAt(i) - '0') % 3 == 2) {
                        if (ct == -1) ct = i;
                        else {
                            remove22 = 2;
                            for (int j = 0; j < i; j++) res22[ptr2++] = s.charAt(j);
                            int j = i + 1;
                            while (i == 0 && j < s.length()) {
                                if (j == ct) {
                                    j++;
                                    continue;
                                } else if (s.charAt(j) != '0') break;
                                zeroDel22 = true;
                                j++;
                                remove22++;
                            }
                            while (j < s.length()) {
                                if (j == ct) {
                                    j++;
                                    continue;
                                }
                                res22[ptr2++] = s.charAt(j++);
                            }
                            break;
                        }
                    }
                }
                if (ptr2 == 0 && zeroDel22) {
                    res22[ptr2++] = '0';
                    remove22--;
                }
                int ans = Math.min(remove1, remove22);
                if (ans > s.length() - 1) out.println(-1);
                else if (remove1 < remove22) {
                    out.println(new String(res1, 0, ptr1));
                } else {
                    out.println(new String(res22, 0, ptr2));
                }
            } else if (sum % 3 == 2) {
                //remove 2
                int remove2 = Integer.MAX_VALUE;
                char[] res2 = new char[s.length()];
                boolean zeroDel2 = false;
                int ptr2 = 0;
                for (int i = s.length() - 1; i >= 0; i--) {
                    if ((s.charAt(i) - '0') % 3 == 2) {
                        remove2 = 1;
                        for (int j = 0; j < i; j++) res2[ptr2++] = s.charAt(j);
                        int j = i + 1;
                        while (i == 0 && j < s.length() && s.charAt(j) == '0') {
                            zeroDel2 = true;
                            j++;
                            remove2++;
                        }
                        while (j < s.length()) res2[ptr2++] = s.charAt(j++);
                        break;
                    }
                }
                if (ptr2 == 0 && zeroDel2) {
                    res2[ptr2++] = '0';
                    remove2--;
                }
                //remove11
                char[] res11 = new char[s.length()];
                int ptr1 = 0;
                boolean zeroDel11 = false;
                int remove11 = Integer.MAX_VALUE;
                int ct = -1;
                for (int i = s.length() - 1; i >= 0; i--) {
                    if ((s.charAt(i) - '0') % 3 == 1) {
                        if (ct == -1) ct = i;
                        else {
                            remove11 = 2;
                            for (int j = 0; j < i; j++) res11[ptr1++] = s.charAt(j);
                            int j = i + 1;
                            while (i == 0 && j < s.length()) {
                                if (j == ct) {
                                    j++;
                                    continue;
                                } else if (s.charAt(j) != '0') break;
                                zeroDel11 = true;
                                j++;
                                remove11++;
                            }
                            while (j < s.length()) {
                                if (j == ct) {
                                    j++;
                                    continue;
                                }
                                res11[ptr1++] = s.charAt(j++);
                            }
                            break;
                        }
                    }
                }
                if (ptr1 == 0 && zeroDel11) {
                    res11[ptr1++] = '0';
                    remove11--;
                }
                int ans = Math.min(remove2, remove11);
                if (ans > s.length() - 1) out.println(-1);
                else if (remove2 < remove11) {
                    out.println(new String(res2, 0, ptr2));
                } else {
                    out.println(new String(res11, 0, ptr1));
                }
            }
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public String scanString() {
            int c = scan();
            if (c == -1) return null;
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}