#include<iostream>
using namespace std;

int main(){
    char x, y;  // ??\?????????????????????
    char comma; // cin??????????????????????????????????????????????????°
    char ball_position = 'A';       // ??????????????????

    while(cin >> x >> comma >> y){
        if (x == ball_position) {
            ball_position = y;
        }else if (y == ball_position) {
            ball_position = x;
        }
    }
    cout << ball_position << endl;
    return 0;
}