#include <iostream>
#include <cstdio>
#include <algorithm>

int main() {
    int cups[] = {1, 0, 0};
    char a, b;
    while (scanf("%c,%c ", &a, &b) != EOF) {
        std::swap(cups[a - 'A'], cups[b - 'A']);
    }
    for (int i = 0; i < 3; i++) {
        if (cups[i]) printf("%c\n", i + 'A');
    }
    return 0;
}