moves = input() moves = list(moves) place = 1 for move in list(moves): if place == 1 and move == 'A': place = 2 elif place == 2 and move == 'A': place = 1 elif place == 1 and move == 'C': place = 3 elif place == 3 and move == 'C': place = 1 elif place == 2 and move == 'B': place = 3 elif place == 3 and move == 'B': place = 2 print(place)