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

int AbcTo012(int ch){
	if(ch=='A') return 0;
	if(ch=='B') return 1;
	if(ch=='C') return 2;
	return -1;
}

int main(){
	char ch1,ch2;
	int tmp, cup[3] = {1,0,0};
	while(scanf("%c,%c", &ch1, &ch2)!= EOF){
		swap(cup[AbcTo012(ch1)], cup[AbcTo012(ch2)]);
	}
	for(int i=0;i<3;i++){
		if(cup[i])printf("%c", 'A'+i);
	}
	return 0;
}