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

import java.io.*;
import java.math.BigInteger;

public class dsu {

	public static class UnionFind {
		int[] p, rank, setSize;
		int numSets;
		Queue<Integer> subs[];

		public UnionFind(int N) {
			p = new int[numSets = N];
			rank = new int[N];
			setSize = new int[N];
			subs = new LinkedList[N];
			for (int i = 0; i < N; i++) {
				subs[i] = new LinkedList<Integer>();
				subs[i].add(i);
				p[i] = i;
				setSize[i] = 1;

			}
		}

		public int findSet(int i) {
			return p[i] == i ? i : (p[i] = findSet(p[i]));
		}

		public boolean isSameSet(int i, int j) {
			return findSet(i) == findSet(j);
		}

		public void unionSet(int i, int j) {
			if (isSameSet(i, j))
				return;
			numSets--;
			int x = findSet(i), y = findSet(j);
			if (rank[x] > rank[y]) {
				p[y] = x;
				while (!subs[y].isEmpty())
					subs[x].add(subs[y].poll());
				setSize[x] += setSize[y];
			} else {
				p[x] = y;
				setSize[y] += setSize[x];
				while (!subs[x].isEmpty())
					subs[y].add(subs[x].poll());
				if (rank[x] == rank[y])
					rank[y]++;
			}
		}

		public int numDisjointSets() {
			return numSets;
		}

		public int sizeOfSet(int i) {
			return setSize[findSet(i)];
		}
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int k) {
			x = d;
			y = k;
		}

		@Override
		public int compareTo(pair arg0) {

			return x - arg0.x;
		}
	}

	static ArrayList<Integer> primes;
	static int[] isComposite;

	static void sieve(int N) // O(N log log N)
	{
		isComposite = new int[N + 1];
		isComposite[0] = isComposite[1] = 1; // 0 indicates a prime number
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i) // can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) // can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				if (1l * i * i <= N)
					for (int j = i * i; j <= N; j += i) // j = i * 2 will not affect performance too much, may alter in
														// modified sieve
						isComposite[j] = 1;
			}
	}

	static boolean isPrime(int N) {
		if (N < isComposite.length)
			return isComposite[N] == 0;
		for (int p : primes) // may stop if p * p > N
			if (N % p == 0)
				return false;
		return true;
	}

	static int m;
	static ArrayList<pair> mask;

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		char a[] = br.readLine().toCharArray();
		int c[] = new int[a.length];
		for (int i = 0; i < c.length; i++) {
			c[i] = Integer.parseInt(a[i] + "");
		}
		int sum = 0;
		int w = 0;
		for (int i = 0; i < c.length; i++) {
			sum += c[i];
		}
		StringBuilder sol = new StringBuilder();
		if (sum % 3 == 0) {
			int i = 0;
			while (i < c.length && c[i] == 0) {
				i++;
			}

			for (int j = i; j < c.length; j++) {
				sol.append(c[j]);
			}
		} else {
			if (sum % 3 == 1) {
				int x = c.length - 1;
				while (x >= 0 && c[x] % 3 != 1)
					x--;
				if (x != -1) {
					int i = 0;
					while (i < c.length && (c[i] == 0 || i == x)) {
						i++;
					}

					for (int j = i; j < c.length; j++) {
						if (j != x)
							sol.append(c[j]);
					}
					w=-1000000000;
				}
				StringBuilder s2=new StringBuilder();
				int l = -1;
				int q = 0;
				x = c.length - 1;
				while (x >= 0 && q != 2) {
					if (c[x] % 3 == 2) {
						if (l == -1)
							l = x;
						q++;
					}
					x--;
				}

				x++;
				int i = 0;
				while (i < c.length && (c[i] == 0 || i == x || i == l)) {
					i++;
				}
				for (int j = i; j < c.length; j++) {
					if (j != x && j != l)
						s2.append(c[j]);
				}
				if(q==2 && w<0) {
					if(sol.length()<s2.length())
						sol=new StringBuilder(s2);
				}
				if(w>=0)
					sol=new StringBuilder(s2);
			
			} else {
				int x = c.length - 1;
				while (x >= 0 && c[x] % 3 != 2)
					x--;
				if (x != -1) {
					int i = 0;
					while (i < c.length && (c[i] == 0 || i == x)) {
						i++;
					}

					for (int j = i; j < c.length; j++) {
						if (j != x)
							sol.append(c[j]);
					}
					w=-1000000000;
				}
				StringBuilder s2=new StringBuilder();
				int l = -1;
				int q = 0;
				x = c.length - 1;
				while (x >= 0 && q != 2) {
					if (c[x] % 3 == 1) {
						if (l == -1)
							l = x;
						q++;
					}
					x--;
				}

				x++;
				int i = 0;
				while (i < c.length && (c[i] == 0 || i == x || i == l)) {
					i++;
				}
				for (int j = i; j < c.length; j++) {
					if (j != x && j != l)
						s2.append(c[j]);
				}
				if(q==2 && w<0) {
					if(sol.length()<s2.length())
						sol=new StringBuilder(s2);
				}
				if(w>=0)
					sol=new StringBuilder(s2);
			}
		}
		if (sol.toString().equals(""))
			sol = new StringBuilder("-1");
		for (int i = 0; i < c.length; i++) {
			if (c[i] == 0 && sol.toString().equals("-1")) {
				sol = new StringBuilder("0");
			}
		}
		pw.print(sol);
		pw.flush();
	}

	public static pair check() {
		int x = -1;
		int y = -1;
		for (int i = 0; i < mask.size(); i++) {
			for (int j = 0; j < mask.size(); j++) {
				if ((mask.get(i).x | mask.get(j).x) == (int) Math.pow(2, m) - 1) {
					x = mask.get(i).y + 1;
					y = mask.get(j).y + 1;
				}
			}
		}
		return new pair(x, y);
	}

	public static int stringCompare(String str1, String str2) {

		int l1 = str1.length();
		int l2 = str2.length();
		int lmin = Math.min(l1, l2);

		for (int i = 0; i < lmin; i++) {
			int str1_ch = (int) str1.charAt(i);
			int str2_ch = (int) str2.charAt(i);

			if (str1_ch != str2_ch) {
				return str1_ch - str2_ch;
			}
		}

		if (l1 != l2) {
			return l1 - l2;
		}

		// If none of the above conditions is true,
		// it implies both the strings are equal
		else {
			return 0;
		}
	}

	static long gcd(long a, long b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	static long lcm(long a, long b) {
		return (a * b / gcd(a, b));
	}

}