#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
  int cup[3] = {1, 0, 0};
  char a, b, dumy;

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