#include <bits/stdc++.h>
using namespace std;

int main () {
    int a = 1, b = 0, c = 0;
    string s1, s2, ans;
    while (cin >> s1 >> s2){
        if((s1 == "A" && s2 == "B") || (s1 == "B" && s2 == "A")){
            swap(a, b);
        }
        if((s1 == "A" && s2 == "C") || (s1 == "C" && s2 == "A")){
            swap(a, c);
        }
        if((s1 == "B" && s2 == "C") || (s1 == "C" && s2 == "B")){
            swap(b, c);
        }
    }

if(a == 1){
    ans = "A";
}
else if (b == 1){
    ans = "B";
}
else{
    ans = "C";
}

cout << ans << endl;
}
