#include <iostream>
using namespace std;

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