#include <iostream>
#define MAX 30
using namespace std;

inline void change(bool a, bool b){
  bool swap = a;
  a = b;
  b = swap;
}

int main(){
  bool cup_A=true, cup_B=false, cup_C=false;
  char comma;
  char change1, change2;

  while (cin >> change1 >> comma >> change2){
    if(change1 == change2){
      break;
    }

    if( (change1 == 'A' && change2 == 'B') || (change1 == 'B' && change2 == 'A') ){
      change(cup_A, cup_B);
    }
    else if( (change1 == 'A' && change2 == 'C') || (change1 == 'C' && change2 == 'A') ){
      change(cup_A, cup_C);
    }
    else if( (change1 == 'B' && change2 == 'C') || (change1 == 'C' && change2 == 'B') ){
      change(cup_B, cup_C);
    }
  }

  if(cup_A){
    cout << "A" << endl;
  }
  if(cup_B){
    cout << "B" << endl;
  }
  if(cup_C){
    cout << "C" << endl;
  }

}