#include<iostream>

using namespace std;

int main() {
	
	char first, second, ch;
	
	int cup[3] = {1, 0, 0};
	
	while( cin >> first >> ch >> second ) {
		
		if( ( first == 'A' && second == 'B' ) || ( first == 'B' && second == 'A' ) )
			swap(cup[0], cup[1]);
			
		else if( ( first == 'A' && second == 'C' ) || ( first == 'C' && second == 'A' ) )
			swap(cup[0], cup[2]);
			
		else
			swap(cup[1], cup[2]);
			
	}
		if(cup[0])
		cout << "A\n";
		
		if(cup[1])
		cout << "B\n";
		
		if(cup[2])
		cout << "C\n";	
		
	return 0;
}

