#P6461. [COCI 2006/2007 #5] TRIK
[COCI 2006/2007 #5] TRIK
Problem Description

There are three upside-down cups, and there is a ball under the leftmost cup at the beginning.
Next, a series of swap operations is performed on these three cups. The operations are given by a string, where A, B, and C correspond to the three swap methods shown in the figure above.
You need to find which cup the ball ends up under.
Input Format
One line containing a string representing the sequence of operations. It is guaranteed that the number of operations does not exceed , and each character is one of A, B, C, with no spaces.
Output Format
Output one line with one integer:
- If the ball is under the left cup, output .
- If the ball is under the middle cup, output .
- If the ball is under the right cup, output .
AB
3
CBABCACCC
1
Hint
Notes
Translated from COCI2006-2007 CONTEST #5 T1 TRIK。
Translated by ChatGPT 5