#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
	map<char, bool> cup;
	cup['A'] = true;
	cup['B'] = false;
	cup['C'] = false;

	while(true){
		pair<char, char> input;
		char c;
		cin >> input.first >> c >> input.second;

		if(cin.eof()) break;

		bool f = cup[input.first];
		cup[input.first] = cup[input.second];
		cup[input.second] = f;
	}
	
	for(map<char, bool>::iterator it = cup.begin(); it != cup.end(); it++){
		if(it->second){
			cout << it->first << endl;
			break;
		}
	}

	return 0;
}