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

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