#include <cstdio>
#include <algorithm>

using namespace std;

#define loop(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) loop(i,0,n)

int pos[]={1,0,0};

int main(){
    char a, b;
    while(scanf("%c,%c",&a,&b)!=EOF){
        swap(pos[a-'A'],pos[b-'A']);
    }
    rep(i,3){
        if(pos[i]){
            printf("%c\n", 'A'+i);
            break;
        }
    }
}