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

public class DivideByThree {
    public static InputReader in;
    public static PrintWriter out;

    public static final int myMotivation = 0;
    public static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
	in = new InputReader(System.in);
	out = new PrintWriter(System.out);
	
	char[] n = in.readString().toCharArray();
	char[] num = n.clone();
	
	boolean containsZero = false;
	for (int i = 0; i < n.length; i++) {
	    containsZero |= n[i] == '0';
	}
	
	int sum = 0;
	int[] count = new int[3];
	for (char c : num) {
	    count[(c - '0')%3]++;
	    sum = (sum + c - '0')%3;
	}
	
	boolean found = true;
	StringBuilder sb1 = new StringBuilder();
	StringBuilder sb2 = new StringBuilder();
	if(sum == 0) {
	    for(int i = num.length - 1; i >= 0; i--) {
		sb1.append(num[i]);
	    }
	} else if(sum == 1) {
	    if(count[1] > 0 && count[2] > 1) {
		boolean virgin = true;
		for(int i = num.length - 1; i >= 0; i--) {
		    if((num[i] - '0')%3 == 1 && virgin) {
			virgin = false;
			continue;
		    }
		    sb1.append(num[i]);
		}
		
		int virginity = 2;
		for(int i = num.length - 1; i >= 0; i--) {
		    if((num[i] - '0')%3 == 2 && virginity > 0) {
			virginity--;
			continue;
		    }
		    sb2.append(num[i]);
		}
		
		if(sb1.length() == 0 && sb2.length() == 0) {
		    found = false;
		}
	    } else if(count[1] > 0) {
		boolean virgin = true;
		for(int i = num.length - 1; i >= 0; i--) {
		    if((num[i] - '0')%3 == 1 && virgin) {
			virgin = false;
			continue;
		    }
		    sb1.append(num[i]);
		}
		if(sb1.length() == 0) {
		    found = false;
		}
	    } else if(count[2] > 1) {
		int virgin = 2;
		for(int i = num.length - 1; i >= 0; i--) {
		    if((num[i] - '0')%3 == 2 && virgin > 0) {
			virgin--;
			continue;
		    }
		    sb2.append(num[i]);
		}
		if(sb2.length() == 0) {
		    found = false;
		}
	    } else {
		found = false;
	    }
	} else {
	    if(count[2] > 0 && count[1] > 1) {
		boolean virgin = true;
		for(int i = num.length - 1; i >= 0; i--) {
		    if((num[i] - '0')%3 == 2 && virgin) {
			virgin = false;
			continue;
		    }
		    sb1.append(num[i]);
		}
		
		
		int virginity = 2;
		for(int i = num.length - 1; i >= 0; i--) {
		    if((num[i] - '0')%3 == 1 && virginity > 0) {
			virginity--;
			continue;
		    }
		    sb2.append(num[i]);
		}
		
		if(sb1.length() == 0 && sb2.length() == 0) {
		    found = false;
		}
	    } else if(count[2] > 0) {
		boolean virgin = true;
		for(int i = num.length - 1; i >= 0; i--) {
		    if((num[i] - '0')%3 == 2 && virgin) {
			virgin = false;
			continue;
		    }
		    sb1.append(num[i]);
		}
		if(sb1.length() == 0) {
		    found = false;
		}
	    } else if(count[1] > 1) {
		int virgin = 2;
		for(int i = num.length - 1; i >= 0; i--) {
		    if((num[i] - '0')%3 == 1 && virgin > 0) {
			virgin--;
			continue;
		    }
		    sb2.append(num[i]);
		}
		if(sb2.length() == 0) {
		    found = false;
		}
	    } else {
		found = false;
	    }
	}
	
	if(!found) {
	    out.println(containsZero ? 0 : -1);
	    out.close();
	    return;
	}
	
	int prefixZeroSize = 0;
	n = sb1.reverse().toString().toCharArray();
	for (int i = 0; i < n.length; i++) {
	    if(n[i] != '0') {
		break;
	    }
	    prefixZeroSize = i + 1;
	}
	
	/*if(prefixZeroSize == n.length) {
	    out.println(containsZero ? 0 : -1);
	    out.close();
	    return;
	}*/
	
	num = new char[n.length - prefixZeroSize];
	for (int i = 0; i < num.length; i++) {
	    num[i] = n[prefixZeroSize + i];
	}
	
	prefixZeroSize = 0;
	n = sb2.reverse().toString().toCharArray();
	for (int i = 0; i < n.length; i++) {
	    if(n[i] != '0') {
		break;
	    }
	    prefixZeroSize = i + 1;
	}
	
	char[] num1 = new char[n.length - prefixZeroSize];
	for (int i = 0; i < num1.length; i++) {
	    num1[i] = n[prefixZeroSize + i];
	}
	
	if(num1.length > num.length && num1.length > 0) {
	    out.println(new String(num1));
	} else if(num.length > 0){
	    out.println(new String(num));
	} else if(containsZero) {
	    out.println(0);
	} else {
	    out.println(-1);
	}

	out.close();
    }

    static class Node implements Comparable<Node> {
	int next;
	int dist;

	public Node(int u, int v) {
	    this.next = u;
	    this.dist = v;
	}

	public void print() {
	    out.println(next + " " + dist + " ");
	}

	public int compareTo(Node that) {
	    return Integer.compare(this.next, that.next);
	}
    }

    static class InputReader {

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

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

	public int snext() {
	    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 = snext();
	    while (isSpaceChar(c))
		c = snext();
	    int sgn = 1;
	    if (c == '-') {
		sgn = -1;
		c = snext();
	    }
	    int res = 0;
	    do {
		if (c < '0' || c > '9')
		    throw new InputMismatchException();
		res *= 10;
		res += c - '0';
		c = snext();
	    } while (!isSpaceChar(c));
	    return res * sgn;
	}

	public long nextLong() {
	    int c = snext();
	    while (isSpaceChar(c))
		c = snext();
	    int sgn = 1;
	    if (c == '-') {
		sgn = -1;
		c = snext();
	    }
	    long res = 0;
	    do {
		if (c < '0' || c > '9')
		    throw new InputMismatchException();
		res *= 10;
		res += c - '0';
		c = snext();
	    } 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 = snext();
	    while (isSpaceChar(c))
		c = snext();
	    StringBuilder res = new StringBuilder();
	    do {
		res.appendCodePoint(c);
		c = snext();
	    } while (!isSpaceChar(c));
	    return res.toString();
	}

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

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