#include<bits/stdc++.h>
using namespace std;

int main(){
  char a, b;
  string tmp = "ABC";
  int ball[3] = {1, 0, 0};
  while(scanf("%c,%c", &a, &b) != EOF){
    int t = ball[tmp.find(a)];
    ball[tmp.find(a)] = ball[tmp.find(b)];
    ball[tmp.find(b)] = t;
  }

  for(int i = 0; i < 3; i++){
    if(ball[i] == 1){
      cout << tmp[i] << endl;
      break;
    }
  }
}