#include <iostream>
using namespace std ;

int main()
{
	int cups[3] = { 1 , 0 , 0 } ;
	char get[3] ;
	int change[2] ;

	while( cin >> get )
	{
		for( int i = 0 ; i < 2 ; i ++ )
		{
			if( get[i*2] == 'A' ) change[i] = 0 ;
			if( get[i*2] == 'B' ) change[i] = 1 ;
			if( get[i*2] == 'C' ) change[i] = 2 ;
		}

		swap( cups[change[0]],cups[change[1]] ) ;
	}

	if( cups[0] == 1 ){ cout << 'A' << endl ; }
	else if( cups[1] == 1 ){ cout << 'B' << endl ; }
	else if( cups[2] == 1 ){ cout << 'C' << endl ; }

	return 0 ;
}