#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main()
{
	char ball='A',s1,s2;
	while(scanf("%c,%c",&s1,&s2)!=EOF)
	{
		if(s1==ball)ball=s2;
		if(s2==ball)ball=s1;
	}
	cout << ball << endl;
	return 0;
}