#include <stdio.h>

int main(void){
    int ball =0x4;
    int swap;
    char buf[8];
    
    while (scanf("%s", buf)!=EOF){
        swap=0;
        swap |= buf[0]=='A'? 0x4 : buf[0]=='B' ? 0x2 : 0x1;
        swap |= buf[2]=='A'? 0x4 : buf[2]=='B' ? 0x2 : 0x1;
        ball ^= swap;
    }
    printf("%c\n", ball==0x4?'A':ball=0x2?'B':'C');

    return 0;
}