#include <iostream>

using namespace std;

typedef long long LL;

int main() {
	char a, f, b;
	char ans = 'A';
	while (cin >> a >> f >> b) {
		if(a == ans){
			ans = b;
		}
		else if (b == ans) {
			ans = a;
		}
	}
	cout << ans << endl;
	return 0;
}
