#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
	int a[3] = {1, 0, 0};
	unsigned char c1, c2;
	while(scanf("%c,%c", &c1, &c2) != EOF) {
		swap(a[c1 - 'A'], a[c2 - 'A']);
	}
	printf("%c\n", a[0] * 'A' + a[1] * 'B' + a[2] * 'C');
}