//Thomas Meeks 6/7/2023
//Solution to Kattis Problem trik utilizing swap function
//https://open.kattis.com/problems/trik
//swap(a,b) is built in to c++ the creation of this function is for demonstration
//the built in version will take in any two variables as long as they are the same type.

#include <iostream>
using namespace std;
//we must take in the two integers we are swapping AS REFERENCE (using the &) so that it swaps the contests of the
//variables that are passed into the function. if we do not this function will not do anything as it will create new local
//variables a,b that only exist inside the scope of the function.
void swapInt(int &a, int &b){
    int temp = a; //must create temp variable to faciliate swap.
    a = b;
    b = temp;
}

int main(){
    //start ball under left most cup
    int cup1 = 1;
    int cup2 = 0;
    int cup3 = 0;

    string s; cin >> s;
    //an alternative way of looping through iterable is for(datatype: iterable), ie vector,string,set,map,etc.
    //since a single element of a string is a character we will use that for our data type.
    for(char c: s){
        //as described in the problem swap different cups depending on the letter in the string
        if(c == 'A') swapInt(cup1,cup2);
        if(c == 'B') swapInt(cup2,cup3);
        if(c == 'C') swapInt(cup1,cup3);
    }
    //since the ball only exists in one spot we do not need else statements (and for this problem there would be no
                                                                             //real speed up in this case)
    if(cup1) cout << 1;
    if(cup2) cout << 2;
    if(cup3) cout << 3;
    return 0;
}
