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

#define A 0
#define B 1 
#define C 2

int c[3] = {1,0,0};

void solve(char i, char j)
{
	swap( c[i-'0'], c[j-'0'] );
}

int main()
{	
	char i,j;
	while( scanf("%c,%c",&i,&j) != EOF){
		solve(i,j);
	}
	if(c[0]==1){
		cout<<"A"<<endl;
	}else if(c[1]==1){
		cout<<"B"<<endl;
	}else if(c[2]==1){
		cout<<"C"<<endl;
	}
	return 0;
}