#include <iostream>
#include <cstdio>
using namespace std;

int main(){
	char o1, o2;
	int a = 1, b = 0, c = 0;
	int *p1, *p2;
	while(scanf("%c,%c", &o1, &o2) != EOF){
		if(o1 == 'A') p1 = &a;
		else if(o1 == 'B') p1 = &b;
		else if(o1 == 'C') p1 = &c;

		if(o2 == 'A') p2 = &a;
		else if(o2 == 'B') p2 = &b;
		else if(o2 == 'C') p2 = &c;

		int s = *p1;
		*p1 = *p2;
		*p2 = s;
	}

	char ans;
	if(a == 1) ans = 'A';
	else if(b == 1) ans = 'B';
	else if(c == 1) ans = 'C';

	cout << ans << endl;
}