#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<char,bool> boll;
void swap(char a,char b){
  bool x;
  x=boll[a];
  boll[a]=boll[b];
  boll[b]=x;
}


int main(){
  char a,b;
  boll['A']=true; boll['B']=false; boll['C']=false;
  while(scanf("%c,%c",&a,&b)+1){
    if(a=='D')break;
    swap(a,b);
  }
  if(boll['A'])cout<<'A'<<endl;
  if(boll['B'])cout<<'B'<<endl;
  if(boll['C'])cout<<'C'<<endl;
}
  
    
   