#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>
#include <stdlib.h>
#include <stack>
#include <queue>
#include <bitset>
#include <memory.h>

using namespace std;



int main() {
    char cup[3]={'A','B','C'};
    int ball[3]={0};
    ball[0]=1;
    char c_cup1, c_cup2;
    while(scanf("%c,%c ",&c_cup1, &c_cup2)!=EOF){

        int i_cup1 = c_cup1-65;
        int i_cup2 = c_cup2-65;
        
        swap(ball[i_cup1],ball[i_cup2]);
    }
    for(int i=0; i<3; i++){
        if(ball[i]==1)cout<<cup[i]<<endl;
    }
}