#include	<iostream>
#include	<cstdio>

using namespace std;

int main(void) {
	char f, t;
	int data[3] = {1, 0, 0};
	while(1) {
		int tmp;
		if( scanf("%c,%c", &f, &t) == EOF )		break;
		tmp = data[t - 'A'];
		data[t - 'A'] = data[f - 'A'];
		data[f - 'A'] = tmp;
	}
	if(data[0] == 1)		cout << 'A' << endl;
	else if(data[1] == 1)	cout << 'B' << endl;
	else					cout << 'C' << endl;
	return 0;
}