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



public class Main {
	
	static InputReader in = new InputReader(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	static int MOD = 1000000007;
	static int M = 505;
	static int oo = (int)1e9;
	
	
	public static void main(String[] args) throws IOException {
		
		char[] num = in.readString().toCharArray();
		int n = num.length;
		int[] a = new int[n];
		for(int i=0; i < n; ++i) {
			a[i] = num[i] - '0';
		}
		
		
		int sum = 0;
		int[] cnt = new int[3];
		for(int i=0; i < n; ++i) {
			sum += a[i];
			cnt[ a[i] % 3 ]++;
		}
		if(sum % 3 == 0) {
			System.out.println(String.valueOf(num));
		}
		else if(sum % 3 == 1) {
			LinkedList<Integer> list1 = null, list2 = null;
			if(cnt[1] >= 1) {
				list1 = new LinkedList<>();
				for(int i=0; i<n; ++i)
					list1.add(a[i]);
				Iterator<Integer> iter = list1.descendingIterator();
				while(iter.hasNext()) {
					int d = iter.next();
					if(d % 3 == 1) {
						iter.remove();
						break;
					}
				}
				iter = list1.iterator();
				while(iter.hasNext()) {
					if(list1.size() == 1)
						break;
					if(iter.next() == 0)
						iter.remove();
					else
						break;
				}
			}
			if(cnt[2] >= 2) {
				list2 = new LinkedList<>();
				for(int i=0; i<n; ++i)
					list2.add(a[i]);
				Iterator<Integer> iter = list2.descendingIterator();
				int rmv = 0;
				while(iter.hasNext()) {
					int d = iter.next();
					if(d % 3 == 2) {
						iter.remove();
						rmv++;
						if(rmv == 2)
							break;
					}
				}
				iter = list2.iterator();
				while(iter.hasNext()) {
					if(list2.size() == 1)
						break;
					if(iter.next() == 0)
						iter.remove();
					else
						break;
				}
			}
			if(list1 != null && list1.isEmpty())
				list1 = null;
			if(list2 != null && list2.isEmpty())
				list2 = null;
			if(list1 == null && list2 == null)
				System.out.println(-1);
			else if(list1 == null)
				print(list2);
			else if(list2 == null)
				print(list1);
			else if(list1.size() > list2.size())
				print(list1);
			else
				print(list2);
		}
		else {
			LinkedList<Integer> list1 = null, list2 = null;
			if(cnt[1] >= 2) {
				list1 = new LinkedList<>();
				for(int i=0; i<n; ++i)
					list1.add(a[i]);
				Iterator<Integer> iter = list1.descendingIterator();
				int rmv = 0;
				while(iter.hasNext()) {
					int d = iter.next();
					if(d % 3 == 1) {
						iter.remove();
						rmv++;
						if(rmv == 2)
							break;
					}
				}
				iter = list1.iterator();
				while(iter.hasNext()) {
					if(list1.size() == 1)
						break;
					if(iter.next() == 0)
						iter.remove();
					else
						break;
				}
			}
			if(cnt[2] >= 1) {
				list2 = new LinkedList<>();
				for(int i=0; i<n; ++i)
					list2.add(a[i]);
				Iterator<Integer> iter = list2.descendingIterator();
				
				while(iter.hasNext()) {
					int d = iter.next();
					if(d % 3 == 2) {
						iter.remove();
						break;
					}
				}
				iter = list2.iterator();
				while(iter.hasNext()) {
					if(list2.size() == 1)
						break;
					if(iter.next() == 0)
						iter.remove();
					else
						break;
				}
			}
			if(list1 != null && list1.isEmpty())
				list1 = null;
			if(list2 != null && list2.isEmpty())
				list2 = null;
			if(list1 == null && list2 == null)
				System.out.println(-1);
			else if(list1 == null)
				print(list2);
			else if(list2 == null)
				print(list1);
			else if(list1.size() > list2.size())
				print(list1);
			else
				print(list2);
		}
		
		out.close();
	}
	
	static void print(List<Integer> list) {
		Iterator<Integer> iter = list.iterator();
		while(iter.hasNext())
			out.print(iter.next());
	}
	
	static void print(char[] a) {
		for(int i=0; i < a.length; ++i) {
			if(a[i] != '-')
				out.print(a[i]);
		}
	}
	
	
	static void shuffle(int[] a) {
		Random r = new Random();
		for(int i = a.length - 1; i > 0; --i) {
			int si = r.nextInt(i);
			int t = a[si];
			a[si] = a[i];
			a[i] = t;
		}
	}
	
	static void shuffle(long[] a) {
		Random r = new Random();
		for(int i = a.length - 1; i > 0; --i) {
			int si = r.nextInt(i);
			long t = a[si];
			a[si] = a[i];
			a[i] = t;
		}
	}
	
	static int lower_bound(int[] a, int n, int k) {
		int s = 0;
		int e = n;
		int m;
		while (e - s > 0) {
			m = (s + e) / 2;
			if (a[m] < k)
				s = m + 1;
			else
				e = m;
		}
		return e;
	}
	static int lower_bound(long[] a, int n, long k) {
		int s = 0;
		int e = n;
		int m;
		while (e - s > 0) {
			m = (s + e) / 2;
			if (a[m] < k)
				s = m + 1;
			else
				e = m;
		}
		return e;
	}
	
	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
	
	static class Pair implements Comparable<Pair> {
		int first, second;

		public Pair(int first, int second) {
			super();
			this.first = first;
			this.second = second;
		}

		@Override
		public int compareTo(Pair o) {
			return this.first != o.first ? this.first - o.first : this.second - o.second;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + first;
			result = prime * result + second;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (first != other.first)
				return false;
			if (second != other.second)
				return false;
			return true;
		}
	}
	
	
}



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;
	}

}