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

int main() {
  int cup[3] = {1};
  char a, c, b;
  while (cin >> a >> c >> b) {
    swap(cup[a - 'A'], cup[b - 'A']);
  }
  if (cup[0] == 1) {
    cout << 'A' << endl;
  }
  if (cup[1] == 1) {
    cout << 'B' << endl;
  }
  if (cup[2] == 1) {
    cout << 'C' << endl;
  }
}

