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.*;
import java.math.*;
import java.util.*;

public class C {
	final static int MOD = 1000000007;
	static ArrayList<Integer> number;
	static int countZ = 0;

	public static void main(String[] args) throws Exception {
		FastReader in = new FastReader(System.in);
		String str = in.next();
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) != '0')
				break;
			countZ++;
		}
		execute(str);
	}
	
	static void execute(String str) {
		number = new ArrayList<>(str.length());
		int count = 0;
		// count leading zeros
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) != '0')
				break;
			count++;
		}
		str = str.substring(count);
		if (str.length() < 1) {
			if (countZ > 0) {
				System.out.println(0);
			} else {
				System.out.println(-1);
			}
			return;
		}
		int sum = 0;
		for (int i = 0; i < str.length(); i++) {
			int cur = Integer.parseInt(str.charAt(i) + "");
			if (cur % 3 == 0 && cur > 0) {
				number.add(3);
				continue;
			}
			number.add(cur % 3);
			sum += cur % 3;
		}
		sum %= 3;
		if (sum == 0) {
			System.out.println(str);
			return;
		} else {
			// if remove a 1
			int oneID = -1;
			for (int i = number.size() - 1; i >= 0; i--)
				if (number.get(i) == sum) {
					oneID = i;
					break;
				}
			if (number.size() <= 1) {
				if (countZ > 0) {
					System.out.println(0);
				} else {
					System.out.println(-1);
				}
				return;
			}
			if (oneID < 0) {
				// no 1, must remove a pair of 2
				int num2 = 0; // count number of 2s
				for (int x : number)
					if (x == 3 - sum)
						num2++;
				if (num2 < 2) {
					if (countZ > 0) {
						System.out.println(0);
					} else {
						System.out.println(-1);
					}
					return;
				} else {
					if (number.size() <= 2) {
						if (countZ > 0) {
							System.out.println(0);
						} else {
							System.out.println(-1);
						}
						return;
					}
					// remove the first 2 and let the function handle the rest
					int twoID = 0;
					for (int i = number.size() - 1; i >= 0; i--) {
						if (number.get(i) == 3 - sum) {
							twoID = i;
							break;
						}
					}
					execute(str.substring(0, twoID) + str.substring(twoID + 1));
				}
				return;
			}
			boolean first = (oneID == 0) && (number.get(1) == 0);
			if (!first) {
				System.out.println(str.substring(0, oneID) + str.substring(oneID + 1));
				return;
			}
			// if is first, count potential leading zeros
			int leadingZ = 0;
			for (int i = 1; i < number.size(); i++) {
				if (number.get(i) != 0)
					break;
				leadingZ++;
			}
			// to be removed: leadingZ + 1
			if (leadingZ + 1 == number.size()) {
				System.out.println(0);
				return;
			}
			
			// if remove a pair of 2
			int num2 = 0; // count number of 2s
			for (int x : number)
				if (x == 3 - sum)
					num2++;
			if (num2 < 2) {
				// remove 1
				System.out.println(str.substring(leadingZ + 1));
				return;
			}
			int twoCount = 0;
			StringBuilder sb = new StringBuilder(str);
			for (int i = number.size() - 1; i >= 0; i--) {
				if (number.get(i) == 3 - sum) {
					twoCount++;
					sb.deleteCharAt(i);
				}
				if (twoCount == 2)
					break;
			}
			System.out.println(sb.toString());
		}
	}

	static class FastReader {
	    private boolean finished = false;

	    private InputStream stream;
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    private SpaceCharFilter filter;

	    public FastReader(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 int peek() {
	        if (numChars == -1) {
	            return -1;
	        }
	        if (curChar >= numChars) {
	            curChar = 0;
	            try {
	                numChars = stream.read(buf);
	            } catch (IOException e) {
	                return -1;
	            }
	            if (numChars <= 0) {
	                return -1;
	            }
	        }
	        return buf[curChar];
	    }

	    public int nextInt() {
	        int c = read();
	        while (isSpaceChar(c))
	            c = read();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = read();
	        }
	        int res = 0;
	        do {
	            if (c == ',') {
	                c = read();
	            }
	            if (c < '0' || c > '9') {
	                throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong() {
	        int c = read();
	        while (isSpaceChar(c))
	            c = read();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = read();
	        }
	        long res = 0;
	        do {
	            if (c < '0' || c > '9') {
	                throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

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

	    public boolean isSpaceChar(int c) {
	        if (filter != null) {
	            return filter.isSpaceChar(c);
	        }
	        return isWhitespace(c);
	    }

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

	    private String readLine0() {
	        StringBuilder buf = new StringBuilder();
	        int c = read();
	        while (c != '\n' && c != -1) {
	            if (c != '\r') {
	                buf.appendCodePoint(c);
	            }
	            c = read();
	        }
	        return buf.toString();
	    }

	    public String nextLine() {
	        String s = readLine0();
	        while (s.trim().length() == 0)
	            s = readLine0();
	        return s;
	    }

	    public String nextLine(boolean ignoreEmptyLines) {
	        if (ignoreEmptyLines) {
	            return nextLine();
	        } else {
	            return readLine0();
	        }
	    }

	    public BigInteger nextBigInteger() {
	        try {
	            return new BigInteger(nextString());
	        } catch (NumberFormatException e) {
	            throw new InputMismatchException();
	        }
	    }

	    public char nextCharacter() {
	        int c = read();
	        while (isSpaceChar(c))
	            c = read();
	        return (char) c;
	    }

	    public double nextDouble() {
	        int c = read();
	        while (isSpaceChar(c))
	            c = read();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = read();
	        }
	        double res = 0;
	        while (!isSpaceChar(c) && c != '.') {
	            if (c == 'e' || c == 'E') {
	                return res * Math.pow(10, nextInt());
	            }
	            if (c < '0' || c > '9') {
	                throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        }
	        if (c == '.') {
	            c = read();
	            double m = 1;
	            while (!isSpaceChar(c)) {
	                if (c == 'e' || c == 'E') {
	                    return res * Math.pow(10, nextInt());
	                }
	                if (c < '0' || c > '9') {
	                    throw new InputMismatchException();
	                }
	                m /= 10;
	                res += (c - '0') * m;
	                c = read();
	            }
	        }
	        return res * sgn;
	    }

	    public boolean isExhausted() {
	        int value;
	        while (isSpaceChar(value = peek()) && value != -1)
	            read();
	        return value == -1;
	    }

	    public String next() {
	        return nextString();
	    }

	    public SpaceCharFilter getFilter() {
	        return filter;
	    }

	    public void setFilter(SpaceCharFilter filter) {
	        this.filter = filter;
	    }

	    public interface SpaceCharFilter {
	        public boolean isSpaceChar(int ch);
	    }
	}
}
