#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

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

int main(){
	string s;
	while(cin >> s){
		int temp1, temp2;
		if(s[0] == 'A') temp1 = 0;
		else if(s[0] == 'B') temp1 = 1;
		else if(s[0] == 'C') temp1 = 2;	
		if(s[2] == 'A') temp2 = 0;
		else if(s[2] == 'B') temp2 = 1;
		else if(s[2] == 'C') temp2 = 2;		
		swap(a[temp1], a[temp2]);
	}
	for(int i = 0; i < 3; i++){
		if(a[i] == 1){
			if(i == 0) cout << "A" << endl;
			if(i == 1) cout << "B" << endl;
			if(i == 2) cout << "C" << endl;
			return 0;
		}
	}
}