#include <iostream>
#include <string>

using namespace std;

int main()
{
	int cup[3] = {1, 0, 0}, c1, c2;
	string str;

	while(cin >> str){
		if(str[0] == 'A')         c1 = 0;
		else if(str[0] == 'B')    c1 = 1;
		else                      c1 = 2;
		if(str[0] == 'A')         c2 = 0;
		else if(str[0] == 'B')    c2 = 1;
		else                      c2 = 2;
	
		if(cup[c1] == 1){
			cup[c1] = 0;
			cup[c2] = 1;
		}
		else if(cup[c2] == 1){
			cup[c2] = 0;
			cup[c1] = 1;
		}
	}

	for(int i = 0; i < 3; i++){
		if(cup[i] == 1){
			if(i == 0)    cout << "A\n";
			if(i == 1)    cout << "B\n";
			if(i == 2)    cout << "C\n";

			break;
		}
	}

	return 0;
}