#include<bits/stdc++.h>
using namespace std;
int main(){
  char x,y,z;
  int P='A';
  while(cin>>x>>z>>y){
    if(x!=P&&y!=P)continue;
    else if(x==P){
      P=y;
      continue;
    }
    else {
      P=x;
      continue;
    }
  }
  cout<<P<<endl;
 return 0;
}