#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

int main(){
	int num[3] = {1,0,0};
	char input1, input2, q;
	while( cin >> input1 >> q >> input2 ){
		int pt1, pt2;
		if( input1 == 'A' ) pt1 = 0;
		else if( input1 == 'B' ) pt1 = 1;
		else if( input1 == 'C' ) pt1 = 2;
		if( input2 == 'A' ) pt2 = 0;
		else if( input2 == 'B' ) pt2 = 1;
		else if( input2 == 'C' ) pt2 = 2;
		
		int tmp = num[pt1];
		num[pt1] = num[pt2];
		num[pt2] = tmp;
	}
	if( num[0] == 1 ) cout << "A" << endl;
	if( num[1] == 1 ) cout << "B" << endl;
	if( num[2] == 1 ) cout << "C" << endl;
	//for( int i = 0; i < 3; i++ ) cout << num[i] << endl;
}