#include<iostream>

using namespace std;

int main(void)
{
	int n[3]={1,0,0};
	char a,b,c;
	while(cin>>a>>c>>b)
	{
		int tmp=n[a-'A'];
		n[a-'A']=n[b-'A'];
		n[b-'A']=tmp;
	}
	for(int i=0;i<3;i++)
	{
		if(n[i]==1)
		{
			cout<<(char)(i+'A')<<endl;
			break;
		}
	}
	return 0;
}