#include<iostream>
using namespace std;

int main()
{
	int a[4] = { 1, 0, 0, -1};
	char x, y;
	char d;

	auto swap = [](int* x, int* y){
		int z = *x;
		*x = *y;
		*y = z;
	};

	auto getNum = [x,y](char z){
		switch (z){
			case 'A':	return 0;
			case 'B':	return 1;
			case 'C':	return 2;
		}				return 3;
	};

	while (cin >> x >> d >> y){
		swap(&a[getNum(x)], &a[getNum(y)]);
	}


	for (int i = 0; i < 3; ++i)
		if (a[i] == 1)
			cout << static_cast<char>('A' + i) << endl;

	return 0;
}