#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	char pos1, pos2, c;
	int cup[] = {1,0,0};
	while(cin >> pos1 >> c >> pos2){
		swap(cup[pos1-'A'], cup[pos2-'A']);
	}
	for(int i = 0 ; i <3; i++){
		if(cup[i]){
			cout << (char)(i+'A') << endl;
			break;
		}
	}

	return 0;
}