#include <iostream>

using namespace std;

int main()
{
	char tmp = 'A', cup1, cup2, t;
	
	while (cin >> cup1 >> t >> cup2) {
		if (cup1 == tmp)
			tmp = cup2;
		if (cup2 == tmp)
			tmp = cup1;
	}
	
	cout << tmp << endl;

	return 0;
}