#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	char k;
	int i,j,A=1,B=0,C=0;
	while(cin>>i>>k>>j){
		if((i =='A' && j=='B')||(i=='B' && j=='A')) swap(A,B);
		if((i =='B' && j=='C')||(i=='C' && j=='B')) swap(B,C);
		if((i =='A' && j=='C')||(i=='C' && j=='A')) swap(A,C);
	}
	if(A==1) cout<<"A"<<endl;
	else if(B==1) cout<<"B"<<endl;
	else if(C==1) cout<<"C"<<endl;
}