#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int arr[3];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);
    arr[0] = 1;

    char a, b;
    while (scanf("%c,%c", &a, &b) != EOF)
    {
        if ((a == 'A' && b == 'B') || (a == 'B' && b == 'A'))
        {
            swap(arr[0], arr[1]);
        }
        else if ((a == 'A' && b == 'C') || (a == 'C' && b == 'A'))
        {
            swap(arr[0], arr[2]);
        }
        else
        {
            swap(arr[1], arr[2]);
        }
    }
    if (arr[0] == 1)
    {
        cout << "A" << endl;
    }
    else if (arr[1] == 1)
    {
        cout << "B" << endl;
    }
    else
    {
        cout << "C" << endl;
    }
    return 0;
}
