#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    char a,b;
    int ans=0;
    char c[3]={'A','B','C'};
    while(scanf("%c,%c",&a,&b)+1){
        int aa,bb;
        if(a=='A'){
            aa=0;
        }else if(a=='B'){
            aa=1;
        }else{
            aa=2;
        }
        if(b=='A'){
            bb=0;
        }else if(b=='B'){
            bb=1;
        }else{
            bb=2;
        }
        if(aa==ans){
            ans=bb;
        }else if(bb==ans){
            ans=aa;
        }
    }
    cout<<c[ans]<<endl;
    return 0;
}


