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.PrintStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Wolfgang Beyer
 */
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 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int sum = 0;
            //int ones = 0;
            //int twos = 0;
            //int zeros = 0;
            List<Integer> a = new ArrayList<>();
            for (int i = 0; i < s.length(); i++) {
                a.add(Integer.parseInt(s.substring(i, i + 1)));
                sum = (sum + a.get(i)) % 3;
                //if (a[i] % 3 == 0) zeros++;
                //else if (a[i] % 3 == 1) ones++;
                //else twos++;
            }

            if (sum == 0) {
                out.println(s);
                return;
            }
            if (s.length() == 1) {
                out.println(-1);
                return;
            }

            //removeLastOne(a);
            //out.println("done");

            if (sum == 1) {
                List<Integer> res1 = removeLeadingZeros(removeLastOne(a));
                List<Integer> res2 = removeLeadingZeros(removeLastTwo(removeLastTwo(a)));
                if ((res1.size() == 0) && (res2.size() == 0)) {
                    out.println(-1);
                    return;
                }
                if (res1.size() > res2.size()) {
                    for (int i = 0; i < res1.size(); i++) out.print(res1.get(i));
                } else {
                    for (int i = 0; i < res2.size(); i++) out.print(res2.get(i));
                }
                return;
            }

            if (sum == 2) {
                List<Integer> res1 = removeLeadingZeros(removeLastTwo(a));
                List<Integer> res2 = removeLeadingZeros(removeLastOne(removeLastOne(a)));
                if ((res1.size() == 0) && (res2.size() == 0)) {
                    out.println(-1);
                    return;
                }
                if (res1.size() > res2.size()) {
                    for (int i = 0; i < res1.size(); i++) out.print(res1.get(i));
                } else {
                    for (int i = 0; i < res2.size(); i++) out.print(res2.get(i));
                }
                return;
            }

        /*if ((ones == 2) && (twos == 0) && (zeros == 0)) {
            out.println(-1);
            return;
        }
        if ((ones == 0) && (twos == 2) && (zeros == 0)) {
            out.println(-1);
            return;
        }

        if (sum == 1) {
            if (ones > 0) {
                boolean skipped = false;
                for (int i = 0; i < s.length(); i++) {
                    int d = Integer.parseInt(s.substring(i, i + 1));
                    if ((d % 3 == 1) && (!skipped)) {
                        skipped = true;
                    } else {
                        out.print(d);
                    }
                }
                return;
            }
            int skippedTwos = 0;
            for (int i = 0; i < s.length(); i++) {
                int d = Integer.parseInt(s.substring(i, i + 1));
                if ((d % 3 == 2) && (skippedTwos < 2)) {
                    skippedTwos++;
                } else {
                    out.print(d);
                }
            }
            return;
        }

        if (sum == 2) {
            if (twos > 0) {
                boolean skipped = false;
                for (int i = 0; i < s.length(); i++) {
                    int d = Integer.parseInt(s.substring(i, i + 1));
                    if ((d % 3 == 2) && (!skipped)) {
                        skipped = true;
                    } else {
                        out.print(d);
                    }
                }
                return;
            }
            int skippedOnes = 0;
            for (int i = 0; i < s.length(); i++) {
                int d = Integer.parseInt(s.substring(i, i + 1));
                if ((d % 3 == 1) && (skippedOnes < 2)) {
                    skippedOnes++;
                } else {
                    out.print(d);
                }
            }
            return;
        }*/
        }

        List<Integer> removeLastOne(List<Integer> a) {
            List<Integer> out = new ArrayList<Integer>(a);
            int idx = out.size() - 1;
            while ((idx > 0) && (out.get(idx) % 3 != 1)) idx--;
            if ((idx >= 0) && (out.get(idx) % 3 == 1)) {
                out.remove((int) idx);
                return out;
            } else {
                return new ArrayList<Integer>();
            }
        }

        List<Integer> removeLastTwo(List<Integer> a) {
            List<Integer> out = new ArrayList<Integer>(a);
            int idx = out.size() - 1;
            while ((idx > 0) && (out.get(idx) % 3 != 2)) idx--;
            if ((idx >= 0) && (out.get(idx) % 3 == 2)) {
                out.remove((int) idx);
                return out;
            } else {
                return new ArrayList<Integer>();
            }
        }

        List<Integer> removeLeadingZeros(List<Integer> a) {

            List<Integer> out = new ArrayList<Integer>(a);
            int idx = out.size() - 1;
            while ((out.size() > 1) && (out.get(0) == 0)) {
                out.remove((int) 0);
            }
            return out;
        }

    }

    static class InputReader {
        private static BufferedReader in;
        private static StringTokenizer tok;

        public InputReader(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            try {
                while (tok == null || !tok.hasMoreTokens()) {
                    tok = new StringTokenizer(in.readLine());
                }
            } catch (IOException ex) {
                System.err.println("An IOException was caught :" + ex.getMessage());
            }
            return tok.nextToken();
        }

    }
}