#include<cstdio>
#include<algorithm>

using namespace std;
int main(void)
{
    int cup[3] = {1};
    char move[2];

    while(scanf("%c,%c",&move[0],&move[1]))
    {
        move[0] -= 'A';
        move[1] -= 'A';
        swap(cup[move[0]],cup[move[1]]);
    }

    for(int i = 0;i < 3;i++)
    {
        if(cup[i] == 1)
        printf("%c\n",'A'+i);
    }

    return 0;
}