#include<stdio.h>

int main(void)
{
	int i,j,k[3]={1,0,0},t;
	char a,b;

	while(scanf("%c,%c",&a,&b) != EOF)
	{
		i=a-65;
		j=b-65;
		t=k[i];
		k[i]=k[j];
		k[j]=t;
	}
   if(k[0] ==1)
	   printf("A");
   else if(k[1] ==1)
	   printf("B");
   else
	   printf("C");

  return 0;
}