#P6461. Cup and Ball Swap Puzzle

    ID: 19675 Type: Default 1000ms 256MiB

Cup and Ball Swap Puzzle

Cup and Ball Swap Puzzle

There are three cups placed in a row with their openings facing downward. A ball is hidden under the left-most cup. You are given a string of operations that represent a series of cup swaps. The three operations are defined as follows:

  • A: Swap the positions of the first and second cups. In LaTeX: $A:\; (1 \leftrightarrow 2)$
  • B: Swap the positions of the second and third cups. In LaTeX: $B:\; (2 \leftrightarrow 3)$
  • C: Swap the positions of the first and third cups. In LaTeX: $C:\; (1 \leftrightarrow 3)$

Your task is to determine under which cup the ball ends up after applying all the swaps.

inputFormat

A single line string consisting only of the characters 'A', 'B', and 'C', which represent the swap operations.

outputFormat

Output a single integer representing the final cup position (1, 2, or 3) under which the ball is located.

sample

A
2