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

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