#include<iostream>
using namespace std;

int main()
{
    int ball[3] = {};
    ball[0] = 1;

    char x, y, p;

    while( cin >> x >> p >> y )
    {
        int s, t;
        if( x == 'A' )
            s = 0;
        else if( x == 'B' )
            s = 1;
        else
            s = 2;

        if( y == 'A' )
            t = 0;
        else if( y == 'B' )
            t = 1;
        else
            t = 2;

        int temp = ball[s];
        ball[s] = ball[t];
        ball[t] = temp;
    }

    if( ball[0] == 1 )
        cout << "A" << endl;
    if( ball[1] == 1 )
        cout << "B" << endl;
    if( ball[2] == 1 )
        cout << "C" << endl;

    return 0;
}
