P6461 [COCI 2006/2007 #5] TRIK

Description

![](https://cdn.luogu.com.cn/upload/image_hosting/edzc5xa4.png) 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 $50$, 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 $1$. - If the ball is under the middle cup, output $2$. - If the ball is under the right cup, output $3$.

Explanation/Hint

#### Notes **Translated from [COCI2006-2007](https://hsin.hr/coci/archive/2006_2007/) [CONTEST #5](https://hsin.hr/coci/archive/2006_2007/contest5_tasks.pdf) *T1 TRIK***。 Translated by ChatGPT 5