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

public class CFEdu18C {
	public static void main(String args[]) {
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		/*------------------------------My Code starts here------------------------------*/
		String s=in.next();
		StringBuilder t1=new StringBuilder("");
		StringBuilder t2=new StringBuilder("");
		int i,n=s.length(),sum=0;
		List<Integer> one=new ArrayList<>();
		List<Integer> two=new ArrayList<>();
		boolean[] a=new boolean[n];
		boolean[] b=new boolean[n];
		Arrays.fill(a, true);
		for(i=0;i<n;i++)
			sum+=(s.charAt(i)-'0');
		for(i=n-1;i>=0;i--)
		{
			if((s.charAt(i)-'0')%3==1)
				one.add(i);
			else if((s.charAt(i)-'0')%3==2)
				two.add(i);
		}
		sum%=3;
		i=0;
		while(i<n && s.charAt(i)=='0')
		{
			a[i]=false;
			i++;
		}
		if(i==n)
		{
			out.println("0");
			out.close();
			return;
		}
		if(sum==1)
		{
			boolean empty=false,empty1=false;
			if(one.isEmpty() && two.size()<2)
			{
				out.println("-1");
				out.close();
				return;
			}
			for(i=0;i<n;i++)
				b[i]=a[i];
			if(one.size()>0)
				a[one.get(0)]=false;
			if(two.size()>1)
			{
				b[two.get(0)]=false;
				b[two.get(1)]=false;
			}
			i=0;
			while(i<n && !a[i])
				i++;
			if(i==n)
				empty=true;
			while(i<n && (s.charAt(i)=='0' || !a[i]))
			{
				a[i]=false;
				i++;
			}
			if(i==n && !empty)
				t1.append('0');
			for(i=0;i<n;i++)
			{
				if(a[i])
					t1.append(s.charAt(i));
			}
			i=0;
			while(i<n && !b[i])
				i++;
			if(i==n)
				empty1=true;
			while(i<n && (s.charAt(i)=='0' || !b[i]))
			{
				b[i]=false;
				i++;
			}
			if(i==n && !empty1)
				t2.append('0');
			for(i=0;i<n;i++)
			{
				if(b[i])
					t2.append(s.charAt(i));
			}
			if(t1.length()>0 && t2.length()>0 && one.size()>0 && two.size()>1)
			{
				if(t1.length()>t2.length())
					out.println(t1);
				else
					out.println(t2);
			}
			else if(t1.length()>0 && one.size()>0)
				out.println(t1);
			else if(t2.length()>0 && two.size()>1)
				out.println(t2);
			else
			{
				out.println("-1");
				out.close();
				return;
			}
		}
		else if(sum==2)
		{
			boolean empty=false,empty1=false;
			if(two.isEmpty() && one.size()<2)
			{
				out.println("-1");
				out.close();
				return;
			}
			for(i=0;i<n;i++)
				b[i]=a[i];
			if(one.size()>1)
			{
				a[one.get(0)]=false;
				a[one.get(1)]=false;
			}
			if(two.size()>0)
				b[two.get(0)]=false;
			i=0;
			while(i<n && !a[i])
				i++;
			if(i==n)
				empty=true;
			while(i<n && (s.charAt(i)=='0' || !a[i]))
			{
				a[i]=false;
				i++;
			}
			if(i==n && !empty)
				t1.append('0');
			for(i=0;i<n;i++)
			{
				if(a[i])
					t1.append(s.charAt(i));
			}
			i=0;
			while(i<n && !b[i])
				i++;
			if(i==n)
				empty1=true;
			while(i<n && (s.charAt(i)=='0' || !b[i]))
			{
				b[i]=false;
				i++;
			}
			if(i==n && !empty1)
				t2.append('0');
			for(i=0;i<n;i++)
			{
				if(b[i])
					t2.append(s.charAt(i));
			}
			if(t1.length()>0 && t2.length()>0 && one.size()>1 && two.size()>0)
			{
				if(t1.length()>t2.length())
					out.println(t1);
				else
					out.println(t2);
			}
			else if(t1.length()>0 && one.size()>1)
				out.println(t1);
			else if(t2.length()>0 && two.size()>0)
				out.println(t2);
			else
			{
				out.println("-1");
				out.close();
				return;
			}
		}
		else
		{
			i=0;
			while(i<n && !a[i])
				i++;
			if(i==n)
			{
				out.println("-1");
				out.close();
				return;
			}
			while(i<n && s.charAt(i)=='0')
			{
				a[i]=false;
				i++;
			}
			if(i==n)
			{
				out.println("0");
				out.close();
				return;
			}
			for(i=0;i<n;i++)
			{
				if(a[i])
					out.print(s.charAt(i));
			}
		}
		out.close();
		/*------------------------------The End------------------------------------------*/
	}

	public static final long l = (int) (1e9 + 7);

	private static int[] nextIntArray(InputReader in, int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();
		return a;
	}

	private static long[] nextLongArray(InputReader in, int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextLong();
		return a;
	}

	private static int[][] nextIntMatrix(InputReader in, int n, int m) {
		int[][] a = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++)
				a[i][j] = in.nextInt();
		}
		return a;
	}

	private static void show(int[] a) {
		for (int i = 0; i < a.length; i++)
			System.out.print(a[i] + " ");
		System.out.println();
	}

	private static void show2DArray(char[][] a) {
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[0].length; j++)
				System.out.print(a[i][j]);
			System.out.println();
		}
	}

	static class Pair {
		private int first;
		private int second;

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

		public int getFirst() {
			return first;
		}

		public int getSecond() {
			return second;
		}

		public void setFirst(int k) {
			this.first = k;
		}

		public void setSecond(int k) {
			this.second = k;
		}
	}

	static int modPow(int a, int b, int p) {
		int result = 1;
		a %= p;
		while (b > 0) {
			if ((b & 1) != 0)
				result = (result * a) % p;
			b = b >> 1;
		a = (a * a) % p;
		}
		return result;
	}

	public static void SieveOfEratosthenes(int n) {
		boolean[] prime = new boolean[n + 1];
		Arrays.fill(prime, true);
		prime[1] = false;
		int i, j;
		for (i = 2; i * i <= n; i++) {
			if (prime[i]) {
				for (j = i; j <= n; j += i) {
					if (j != i)
						prime[i] = false;
				}
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine() {
			String fullLine = null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine = reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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

}