#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	char x,y,p='A';
	while(scanf("%c,%c",&x,&y)!=EOF){
		if(x==p){
			x=y;
			y=p;
			p=x;
		}else if(y==p){
			y=x;
			x=p;
			p=y;
		}
	}
	cout<<p<<endl;
	return 0;
}