Chop Cup

Track which of three cups hides the ball after a sequence of swaps given as letters A, B, and C.

Easy2SimulationImplementationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Oisín is an amateur magician and a big fan of the chop cup routine, which uses three cups turned face down and one ball hidden under one of them. He has only just started practising the trick and wants to test whether you can follow the ball without any tricks or sleight of hand.

The ball starts under the leftmost cup. Oisín then repeats a swap of two cups a number of times, each time choosing one of three moves.

  • A: swap the left cup and the middle cup.
  • B: swap the middle cup and the right cup.
  • C: swap the left cup and the right cup.

The ball travels with the cup that covers it.

What Oisín does not realise is that you are recording the moves on your phone as the letters A, B and C, and that you are going to run a simple program to work out where the ball is. Write that program.

Input

The first and only line contains the string of Oisín's moves. Its length is between 1 and 50, and each character is 'A', 'B' or 'C'.

Output

Print the number of the cup that hides the ball: 1 for the left cup, 2 for the middle cup, 3 for the right cup.