#include <iostream>
#include <vector>
#include <algorithm>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int a = 1;
	int b = 0;
	int c = 0;
	char c0, c1;

#if INPUT_FROM_FILE
	//std::ifstream ifs("test.txt");
	FILE *fp = fopen("test.txt", "r");
#endif

	
#if INPUT_FROM_FILE
	while(fscanf(fp, "%c,%c", &c0, &c1) != EOF){
#else
	while(scanf("%c,%c", &c0, &c1) != EOF){
#endif
		if((c0 == 'A' && c1 == 'B') || (c0 == 'B' && c1 == 'A')){
			std::swap(a, b);
		}
		else if((c0 == 'A' && c1 == 'C') || (c0 == 'C' && c1 == 'A')){
			std::swap(a, c);
		}
		else{
			std::swap(b, c);
		}
			
	}

	if(a > 0){
		std::cout << "A" << std::endl;
	}
	else if(b > 0){
		std::cout << "B" << std::endl;
	}
	else{
		std::cout << "C" << std::endl;
	}
	return 0;
}

