#include<iostream>
#include<string>

using namespace std;

int main()
{
  int cup[3] = {1,0,0};
  string cupa("A");
  string cupb("B");
  string cupc("C");    
  string swapping;

  int a = 0;
  int b = 100;

  while (cin >> swapping){
    int temp;
    if(swapping[0] == cupa && swapping[2] == cupb || swapping[0] == cupb && swapping[2] == cupa){
      temp = cup[0];
      cup[0] = cup[1];
      cup[1] = temp;
    }
    else if(swapping[0] == cupa && swapping[2] == cupc || swapping[0] == cupc && swapping[2] == cupa){
      temp = cup[0];
      cup[0] = cup[2];
      cup[2] = temp;
    }
    else if(swapping[0] == cupb && swapping[2] == cupc || swapping[0] == cupc && swapping[2] == cupb){
      temp = cup[1];
      cup[1] = cup[2];
      cup[2] = temp;
    }
  }
  
  if(cup[0] == 1){
    cout<<cupa<<endl;
  }
  else if(cup[1] == 1){
    cout<<cupb<<endl;
  }
  else if(cup[2] == 1){
    cout<<cupc<<endl;
  }
  
  return 0;
}
