#include<iostream>
#include<cstdio>

int main(void){
	char ball = 'A';

	while( 1 ){
		char a, b;
		
		if( 2 != scanf("%c%*c%c", &a, &b) ) break;
		if( a == ball ) ball = b;
		if( b == ball ) ball = a;
	}
	printf("%c\n", ball);
	return 0;
}