#include <iostream>
using namespace std;

void swap(int a, int b, char* cup)
{
	char temp;
	temp = cup[a];
	cup[a] = cup[b];
	cup[b] = temp;
}

int main(void)
{
	char cup[3] = { 'A' , 'B', 'C'}, a, b, ch;
	int na, nb;

	while (cin >> a >> ch >> b)
	{
		if (a == 'A') na = 0;
		else if (a == 'B') na = 1;
		else na = 2;
		if (b == 'A') nb = 0;
		else if (b == 'B') nb = 1;
		else nb = 2;
		swap(na, nb, cup);
	//	for (int i = 0; i < 3; i++) cout << cup[i] << " ";
	//	cout << endl;
	}
	for (int i = 0; i < 3; i++)
	{
		if (cup[i] == 'A')
		{
			if (i == 0) cout << "A" << endl;
			else if (i == 1) cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
	return 0;
}
