#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

bool a,b,c;

void swap(int k){
	bool t;
	if(k==0){
		t=a;
		a=b;
		b=t;
	}
	else if(k==1){
		t=a;
		a=c;
		c=t;
	}
	else if(k==2){
		t=b;
		b=c;
		c=t;
	}
	//cout<<s<<" "<<u<<"aaa"<<endl;
	//cout<<"hoge"<<endl;
	return;
}

int main(){
	a=true;
	b=c=false;
	//cout<<a<<" "<<b<<" "<<c<<endl;
	string s;
	while(cin>>s){
		if(s=="A,B"||s=="B,A") swap(0);
		else if(s=="A,C"||s=="C,A") swap(1);
		else if(s=="C,B"||s=="B,C") swap(2);
		//cout<<a<<" "<<b<<" "<<c<<endl;
		
	}
	//cout<<a<<" "<<b<<" "<<c<<endl;
	if(a==true) cout<<"A\n";
	else if(b==true) cout<<"B\n";
	else if(c==true) cout<<"C\n";
	return 0;
}
		
		