#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
	bool cup[3] = { true, false, false };
	char x, y;

	while (true)
	{
		if (scanf("%c,", &x) == -1) break;
		scanf("%c", &y);
		swap(cup[x - 'A'], cup[y - 'A']);
	}
	for (int i = 0; i < 3; i++)
	{
		if (cup[i]) printf("%c\n", char(i + 'A'));
	}

	return 0;
}