#include <bits/stdc++.h>
using namespace std;

int main() {
	int cups[3] = {0};
	cups[0] = 1;
	char a, b;
	while(scanf("%c,%c", &a, &b) != EOF){
		int l = a - 'A', r = b - 'A';
		swap(cups[l], cups[r]);
	}
	for(int i = 0; i < 3; ++i){
		if(cups[i]){
			printf("%c\n", i + 'A');
			break;
		}
	}
	return 0;
}