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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;

public class Main {

	static int INF = 987654321;
	
	public static void main(String[] args) {
//		Scanner scan = new Scanner(System.in);
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		String input = in.readString();
		char a[] = input.toCharArray();
		LinkedList<Integer> n = new LinkedList<>();
		PriorityQueue<Integer> r1 = new PriorityQueue<>(Collections.reverseOrder());
		PriorityQueue<Integer> r2 = new PriorityQueue<>(Collections.reverseOrder());
		
		
		int sum = 0;
		for(int i=0; i<a.length; ++i) {
			int x = (int)(a[i] - '0'); 
			n.add(x);
			if(x % 3 == 1)
				r1.add(i);
			else if(x % 3 == 2)
				r2.add(i);
			sum += x;
		}
		
		
		if(sum % 3 == 0)
			out.println(input);
		else {
			int e1= INF, e2 = INF;
			LinkedList<Integer> c1 = new LinkedList<Integer>(n);
			LinkedList<Integer> c2 = new LinkedList<Integer>(n);
			
			if(sum % 3 == 1) {
				if(r1.size() >= 1) {
					c1.remove((int)r1.remove());
					e1 = 1;
					while(!c1.isEmpty() && c1.get(0) == 0) {
						if(c1.size() == 1) break;
						c1.remove(0);
						e1++;
					}
					if(c1.isEmpty())
						e1 = INF;
				}
				if(r2.size() >= 2) {
					c2.remove((int)r2.remove());
					c2.remove((int)r2.remove());
					e2 = 2;
					while(!c2.isEmpty() && c2.get(0) == 0) {
						if(c2.size() == 1) break;
						c2.remove(0);
						e2++;
					}
					if(c2.isEmpty())
						e2 = INF;
				}
			} else if(sum % 3 == 2) {
				if(r1.size() >= 2) {
					c1.remove((int)r1.remove());
					c1.remove((int)r1.remove());
					e1 = 2;
					while(!c1.isEmpty() && c1.get(0) == 0) {
						if(c1.size() == 1) break;
						c1.remove(0);
						e1++;
					}
					if(c1.isEmpty())
						e1 = INF;
				}
				if(r2.size() >= 1) {
					c2.remove((int)r2.remove());
					e2 = 1;
					while(!c2.isEmpty() && c2.get(0) == 0) {
						if(c2.size() == 1) break;
						c2.remove(0);
						e2++;
					}
					if(c2.isEmpty())
						e2 = INF;
				}
			}
			if(e1 == INF && e2 == INF)
				out.println(-1);
			else if(e1 <= e2) {
				for(int x : c1) {
					out.print(x);
				}
			} else {
				for(int x : c2) {
					out.print(x);
				}
			}
		}

		out.close();
//		scan.close();
	}
}


class InputReader {

	private final InputStream stream;
	private final byte[] buf = new byte[8192];
	private int curChar, snumChars;

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

	public int read() {
		if (snumChars == -1)
			throw new InputMismatchException();
		if (curChar >= snumChars) {
			curChar = 0;
			try {
				snumChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (snumChars <= 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 {
			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 {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public int[] nextIntArray(int n) {
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public String readString() {
		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 String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

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

	private boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

}