#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	char a,b;
	char best = 'A';
	while( scanf("%c,%c") != EOF){
		if(best==a) best = b;
		else if(best==b) best = a;
	}
	cout<<best<<endl;
	return 0;
}