#include<iostream>
using namespace std;

int main()
{
    int b[] = {1, 0, 0};
    char x, c, y;
    while(cin >> x >> c >> y) {
        int xi = x - 'A';
        int yi = y - 'A';
        int tmp = b[xi]; b[xi] = b[yi]; b[yi] = tmp;
    }
    for (int i = 0; i < 3; ++i) {
        if (b[i]) {
            cout << (char)('A' + i) << endl;
            break;
        }
    }
}

