#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
	char X = 'A', Y = 'A', P = 'A';

	while (scanf("%c,%c", &X, &Y))
	{
		if (X == P)
		{
			P = Y;
		}
		else if (Y == P)
		{
			P = X;
		}
	}

	printf("%c\n", P);

	return 0;
}