#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	char from, to;
	int ball[3] = {1,0,0};
	while (scanf("%c,%c",&from,&to)!=EOF) {
		swap(ball[from-'A'], ball[to-'A']);
	}
	int res = (int)find(ball, ball+2,1);
	switch(res) {
		case 0:
			cout << "A" << endl;
			break;
		case 1:
			cout << "B" << endl;
			break;
		case 2:
			cout << "C" << endl;
			break;
	}
}