#include<iostream>
using namespace std;
int main(){
  char d[3],c[3],ansk;
  int k=0,k2=0;
  c[0] = 'A';
  c[1] = 'B';
  c[2] = 'C';
  while(cin>>d[0]>>d[1]>>d[2]){
    for(int i=0;i<3;i++){
      if(c[i]==d[0]||c[i]==d[2]){
	if(k==0) k = i;
	else k2 = i;
      }
    }
    ansk = c[k];
    c[k] = c[k2];
    c[k2] = ansk;
    k = 0; 
    k2 = 0;
  }
  for(int i=0;i<3;i++){
    if(c[i]=='A'){
      if(i==0) cout << 'A' << endl;
      else if(i==1) cout << 'B' << endl;
      else if(i==2) cout << 'C' << endl;
    }
  }
  return 0;
}