#include <stdio.h>

int main()
{
	char c1, c2, t, pos[3] = {'A', 'B', 'C'};
	int p1, p2, i;

	while(scanf("%c,%c", &c1, &c2) != EOF){
		for (i = 0; i < 3; i++){
			if(pos[i] == c1) p1 = i;
			else if(pos[i] == c2) p2 = i;
		}

		t = pos[p1]; pos[p1] = pos[p2]; pos[p2] = t;
	}

	for (i = 0; i < 3; i++){
		if(pos[i] == 'A') break;
	}

	switch(i){
		case 0:
			printf("A\n");
			break;
		case 1:
			printf("B\n");
			break;
		case 2:
			printf("C\n");
			break;
	}
	
	return 0;
}