#include <iostream>
using namespace std;

int main(void){
	bool a=true,b=false,c=false;
	char x,y,ch;

	while(cin>>x>>ch>>y){
		if(x=='A' && y == 'B') swap(a,b);
		else if(x=='A' && y == 'C') swap(a,c);
		else swap(b,c);
	}
	if(a) cout<<"A\n";
	if(b) cout<<"B\n";
	if(c) cout<<"C\n";

	return 0;
}