#include <iostream>
#include <cstdio>
using namespace std;



int main(){
    char x,y;
    char ans='A';
    while(scanf("%c,%c",&x,&y)!=EOF){
        if(x==ans){
            ans=y;
        }else if(y==ans){
            ans==x;
        }
    }
    cout << ans << endl;
    return 0;
}