14714 - Tic-Tac-Toe   

Description

Write a program to play tic-tac-toe.

We use the numbers 1 to 9 to represent the nine squares of the tic-tac-toe board from top to bottom, left to right: 1 represents the top-left corner, and 9 represents the bottom-right corner.

The input is a single line containing the sequence of moves made by both players, up to 9 numbers.

If either player wins, output the last number placed by the winning player.

If the game ends in a draw, output 0.

Input

The sequence of moves made by both players, up to 9 numbers.

Ex. 6 4 2 7 5 9 3

Output

If either player wins, output the last number placed by the winning player.

If the game ends in a draw, output 0.

Ex. 0

Sample Input  Download

Sample Output  Download

Tags

11410EE 231002



Discuss