#include<iostream>
using namespace std;

int main(){
	int a = 1, b = 0, c = 0;
	char x, y, w;
	while(cin >> x >> w >> y){
		if(x == 'A' && y == 'B') swap(a, b);
		else if(x == 'A' && y == 'C') swap(a, c);
		else if(x == 'B' && y == 'A') swap(b, a);
		else if(x == 'B' && y == 'C') swap(b, c);
		else if(x == 'C' && y == 'A') swap(c, a);
		else if(x == 'C' && y == 'B') swap(c, b);
	}
	if(a == 1) cout << 'A' << endl;
	else if(b == 1) cout << 'B' << endl;
	else if(c == 1) cout << 'C' << endl;

}