#include <iostream>
using namespace std;

char cup[3] = {'A','B','C'};

void swap(char a,char b)
{
	char tmp;
	for(int i=0;i<3;i++){
		if(cup[i] == a){
			for(int j=0;j<3;j++){
				if(cup[j] == b){
					tmp = cup[i];
					cup[i] = cup[j];
					cup[j] = tmp;
				}
			}
		}
	}
}
int main()
{
	char a,b,dot;
	while(cin >>a && cin >> dot && cin >> b){
		swap(a,b);
	}
	cout << cup[0] << endl;
	return 0;
}