#include <iostream>

using namespace std;

int ctoi(char c){
  if(c=='A')
    return 0;
  if(c=='B')
    return 1;
  if(c=='C')
    return 2;
}

int main(void)
{
  bool cup[3];
  char x,y,c;
  int a,b;
  
  cup[0]=1;
  cup[1]=0;
  cup[2]=0;

  while(cin >> x >> c >> y)
    {
      a=ctoi(x);
      b=ctoi(y);
      swap(cup[a],cup[b]);
    }

  for(int i=0;i<3;i++)
    {
      if(cup[i]==1)
	{
	  if(i==0)
	    cout << "A" <<endl;
	  if(i==1)
	    cout << "B" <<endl;
	  else
	    cout << "C" <<endl;
	}
    }
  
  return 0;
}


