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.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main implements Runnable {
    int n, m, k;
    static boolean use_n_tests = false;

    void solve(FastScanner in, PrintWriter out, int testNumber) {
        char[] c = in.nextc();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += (c[i] - '0');
        }
        if (sum % 3 == 0) {
            out.println(c);
        } else {
            int r = sum % 3;
            int one1 = -1;
            int one2 = -1;
            int two1 = -1;
            int two2 = -1;
            for (int i = c.length - 1; i >= 0; i--) {
                if ((c[i] - '0') % 3 == 2) {
                    if (two1 == -1) {
                        two1 = i;
                    } else if (two2 == -1) {
                        two2 = i;
                    }
                }
                if ((c[i] - '0') % 3 == 1) {
                    if (one1 == -1) {
                        one1 = i;
                    } else if (one2 == -1) {
                        one2 = i;
                    }
                }
            }
            boolean yes = false;
            if (r == 1) {
                int oneTake = 1;
                if (one1 == 0) {
                    int c1 = 1;
                    while (c1 < c.length && c[c1] == '0') {
                        oneTake++;
                        c1++;
                    }
                }
                if ((oneTake >= 2 || one1 == -1) && two1 != -1 && two2 != -1) {
                    c[two1] = 0;
                    c[two2] = 0;
                    if (c.length != 2) {
                        yes = true;
                    }
                } else if (one1 != -1) {
                    c[one1] = 0;
                    if (c.length != 1) {
                        yes = true;
                    }
                }
            } else if (r == 2) {
                int twoTake = 1;
                if (two1 == 0) {
                    int c1 = two1 + 1;
                    while (c1 < c.length && c[c1] == '0') {
                        twoTake++;
                        c1++;
                    }
                }
                if ((twoTake >= 2 || two1 == -1) && one1 != -1 && one2 != -1) {
                    c[one1] = 0;
                    c[one2] = 0;
                    if (c.length != 2) {
                        yes = true;
                    }
                } else if (two1 != -1){
                    c[two1] = 0;
                    if (c.length != 1) {
                        yes = true;
                    }
                }
            }
            if (yes) {
                int start = 0;
                if (c[0] == 0) {
                    while (start < c.length && (c[start] == 0 || c[start] == '0')) {
                        start++;
                    }
                }
                if (start == c.length) {
                    out.println(0);
                } else {
                    for (int i = start; i < c.length; i++) {
                        if (c[i] != 0) {
                            out.print(c[i]);
                        }
                    }
                    out.println();
                }
            } else {
                out.println(-1);
            }

        }
    }

    int rec(int id, int n, int k, int dir) {
        return 0;
        //        int ans = 1;
        //        if (k > 1) {
        //            if (dir == 1) {
        //                ans += rec(id + 1, n - 1, k, dir);
        //                ans += rec(id - 1, n + 1, k - 1, 1 - dir);
        //            } else {
        //                ans += rec(id - 1, n + 1, k, dir);
        //                ans += rec(id + 1, n - 1, k - 1, 1 - dir);
        //            }
        //        }
    }


    long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public class NextPermutation {
        // Function to swap the data
        // present in the left and right indices
        public int[] swap(int data[], int left, int right) {

            // Swap the data
            int temp = data[left];
            data[left] = data[right];
            data[right] = temp;

            // Return the updated array
            return data;
        }

        // Function to reverse the sub-array
        // starting from left to the right
        // both inclusive
        public int[] reverse(int data[], int left, int right) {

            // Reverse the sub-array
            while (left < right) {
                int temp = data[left];
                data[left++] = data[right];
                data[right--] = temp;
            }

            // Return the updated array
            return data;
        }

        // Function to find the next permutation
        // of the given integer array
        public boolean findNextPermutation(int data[]) {

            // If the given dataset is empty
            // or contains only one element
            // next_permutation is not possible
            if (data.length <= 1)
                return false;

            int last = data.length - 2;

            // find the longest non-increasing suffix
            // and find the pivot
            while (last >= 0) {
                if (data[last] < data[last + 1]) {
                    break;
                }
                last--;
            }

            // If there is no increasing pair
            // there is no higher order permutation
            if (last < 0)
                return false;

            int nextGreater = data.length - 1;

            // Find the rightmost successor to the pivot
            for (int i = data.length - 1; i > last; i--) {
                if (data[i] > data[last]) {
                    nextGreater = i;
                    break;
                }
            }

            // Swap the successor and the pivot
            data = swap(data, nextGreater, last);

            // Reverse the suffix
            data = reverse(data, last + 1, data.length - 1);

            // Return true as the next_permutation is done
            return true;
        }
    }

    // ****************************** template code ***********
    List<Integer> getGidits(long n) {
        List<Integer> res = new ArrayList<>();
        while (n != 0) {
            res.add((int) (n % 10L));
            n /= 10;
        }
        return res;
    }

    List<Integer> generatePrimes(int n) {
        List<Integer> res = new ArrayList<>();
        boolean[] sieve = new boolean[n + 1];
        for (int i = 2; i <= n; i++) {
            if (!sieve[i]) {
                res.add(i);
            }
            if ((long) i * i <= n) {
                for (int j = i * i; j <= n; j += i) {
                    sieve[j] = true;
                }
            }
        }
        return res;
    }

    int ask(int l, int r) {
        if (l >= r) {
            return -1;
        }
        System.out.printf("? %d %d\n", l + 1, r + 1);
        System.out.flush();
        return in.nextInt() - 1;
    }

    static int stack_size = 1 << 27;

    class Mod {
        long mod;

        Mod(long mod) {
            this.mod = mod;
        }

        long add(long a, long b) {
            a = mod(a);
            b = mod(b);
            return (a + b) % mod;
        }

        long sub(long a, long b) {
            a = mod(a);
            b = mod(b);
            return (a - b + mod) % mod;
        }

        long mul(long a, long b) {
            a = mod(a);
            b = mod(b);
            return a * b % mod;
        }

        long div(long a, long b) {
            a = mod(a);
            b = mod(b);
            return (a * inv(b)) % mod;
        }

        public long inv(long r) {
            if (r == 1)
                return 1;
            return ((mod - mod / r) * inv(mod % r)) % mod;
        }

        private long mod(long a) {
            return a % mod;
        }
    }

    static class Coeff {
        long mod;
        long[][] C;
        long[] fact;
        boolean cycleWay = false;

        Coeff(int n, long mod) {
            this.mod = mod;
            fact = new long[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++) {
                fact[i] = i;
                fact[i] %= mod;
                fact[i] *= fact[i - 1];
                fact[i] %= mod;
            }
        }

        Coeff(int n, int m, long mod) {
            // n > m
            cycleWay = true;
            this.mod = mod;
            C = new long[n + 1][m + 1];
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= Math.min(i, m); j++) {
                    if (j == 0 || j == i) {
                        C[i][j] = 1;
                    } else {
                        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
                        C[i][j] %= mod;
                    }
                }
            }
        }

        public long C(int n, int m) {
            if (cycleWay) {
                return C[n][m];
            }
            return fC(n, m);
        }

        private long fC(int n, int m) {
            return (fact[n] * inv(fact[n - m] * fact[m] % mod)) % mod;
        }

        private long inv(long r) {
            if (r == 1)
                return 1;
            return ((mod - mod / r) * inv(mod % r)) % mod;
        }
    }

    class Pair {
        int first;
        long second;

        Pair(int f, long s) {
            first = f;
            second = s;
        }

        public int getFirst() {
            return first;
        }

        public long getSecond() {
            return second;
        }
    }

    class MultisetTree<T> {
        int size = 0;

        TreeMap<T, Integer> mp = new TreeMap<>();

        void add(T x) {
            mp.merge(x, 1, Integer::sum);
            size++;
        }

        void remove(T x) {
            if (mp.containsKey(x)) {
                mp.merge(x, -1, Integer::sum);
                if (mp.get(x) == 0) {
                    mp.remove(x);
                }
                size--;
            }
        }

        boolean contains(T x) {
            return mp.containsKey(x);
        }

        T greatest() {
            return mp.lastKey();
        }

        T smallest() {
            return mp.firstKey();
        }

        int size() {
            return size;
        }

        int diffSize() {
            return mp.size();
        }
    }

    class Multiset<T> {
        int size = 0;

        Map<T, Integer> mp = new HashMap<>();

        void add(T x) {
            mp.merge(x, 1, Integer::sum);
            size++;
        }

        boolean contains(T x) {
            return mp.containsKey(x);
        }

        void remove(T x) {
            if (mp.containsKey(x)) {
                mp.merge(x, -1, Integer::sum);
                if (mp.get(x) == 0) {
                    mp.remove(x);
                }
                size--;
            }
        }

        int size() {
            return size;
        }

        int diffSize() {
            return mp.size();
        }
    }

    static class Range {
        int l, r;
        int id;

        public int getL() {
            return l;
        }

        public int getR() {
            return r;
        }

        public Range(int l, int r, int id) {
            this.l = l;
            this.r = r;
            this.id = id;
        }
    }

    static class Array {
        static Range[] readRanges(int n, FastScanner in) {
            Range[] result = new Range[n];
            for (int i = 0; i < n; i++) {
                result[i] = new Range(in.nextInt(), in.nextInt(), i);
            }
            return result;
        }

        static List<List<Integer>> intInit2D(int n) {
            List<List<Integer>> res = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                res.add(new ArrayList<>());
            }
            return res;
        }

        static boolean isSorted(Integer[] a) {
            for (int i = 0; i < a.length - 1; i++) {
                if (a[i] > a[i + 1]) {
                    return false;
                }
            }
            return true;
        }

        static public long sum(int[] a) {
            long sum = 0;
            for (int x : a) {
                sum += x;
            }
            return sum;
        }

        static public long sum(long[] a) {
            long sum = 0;
            for (long x : a) {
                sum += x;
            }
            return sum;
        }

        static public long sum(Integer[] a) {
            long sum = 0;
            for (int x : a) {
                sum += x;
            }
            return sum;
        }

        static public int min(Integer[] a) {
            int mn = Integer.MAX_VALUE;
            for (int x : a) {
                mn = Math.min(mn, x);
            }
            return mn;
        }

        static public int min(int[] a) {
            int mn = Integer.MAX_VALUE;
            for (int x : a) {
                mn = Math.min(mn, x);
            }
            return mn;
        }

        static public int max(Integer[] a) {
            int mx = Integer.MIN_VALUE;
            for (int x : a) {
                mx = Math.max(mx, x);
            }
            return mx;
        }

        static public int max(int[] a) {
            int mx = Integer.MIN_VALUE;
            for (int x : a) {
                mx = Math.max(mx, x);
            }
            return mx;
        }

        static public int[] readint(int n, FastScanner in) {
            int[] out = new int[n];
            for (int i = 0; i < out.length; i++) {
                out[i] = in.nextInt();
            }
            return out;
        }
    }

    class Graph {
        List<List<Integer>> graph;

        Graph(int n) {
            create(n);
        }

        private void create(int n) {
            List<List<Integer>> graph = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                graph.add(new ArrayList<>());
            }
            this.graph = graph;
        }

        void readBi(int m, FastScanner in) {
            for (int i = 0; i < m; i++) {
                int v = in.nextInt() - 1;
                int u = in.nextInt() - 1;
                graph.get(v).add(u);
                graph.get(u).add(v);
            }
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream io) {
            br = new BufferedReader(new InputStreamReader(io));
        }

        public String line() {
            String result = "";
            try {
                result = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return result;
        }

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

        public char[] nextc() {
            return next().toCharArray();
        }

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

        public int[] nextArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = in.nextInt();
            }
            return res;
        }

        public long[] nextArrayL(int n) {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) {
                res[i] = in.nextLong();
            }
            return res;
        }

        public Long[] nextArrayL2(int n) {
            Long[] res = new Long[n];
            for (int i = 0; i < n; i++) {
                res[i] = in.nextLong();
            }
            return res;
        }


        public Integer[] nextArray2(int n) {
            Integer[] res = new Integer[n];
            for (int i = 0; i < n; i++) {
                res[i] = in.nextInt();
            }
            return res;
        }

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

    }

    void run_t_tests() {
        int t = in.nextInt();
        int i = 0;
        while (t-- > 0) {
            solve(in, out, i++);
        }
    }

    void run_one() {
        solve(in, out, -1);
    }

    @Override
    public void run() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        if (use_n_tests) {
            run_t_tests();
        } else {
            run_one();
        }
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(null, new Main(), "", stack_size);
        thread.start();
        thread.join();
    }
}