#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <string.h>

int main(void)
{
	int A = 1, B = 0, C = 0, box = 0;
	char a[2];

	while (scanf("%s", a) != EOF){
		if (((a[0] == 'A') && (a[1] == 'B')) || ((a[0] == 'B') && (a[1] == 'A'))){
			box = A;
			A = B;
			B = box;
		}
		else if (((a[0] == 'A') && (a[1] == 'C')) || ((a[0] == 'C') && (a[1] == 'A'))){
			box = A;
			A = C;
			C = box;
		}
		else if (((a[0] == 'B') && (a[1] == 'C')) || ((a[0] == 'C') && (a[1] == 'B'))){
			box = B;
			B = C;
			C = box;
		}
	}

	if (A == 1){
		putchar('A');
	}
	else if (B == 1){
		putchar('B');
	}
	else if (C == 1){
		putchar('C');
	}

	putchar('\n');

	return 0;
}