#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	char cup = 'A';
	string s;
	while(cin >> s) {
		char x = 0, y = 0;
		for(int i = 0; s[i] != '\0'; i++) {
			if(isalpha(s[i])) {
				if(!x) x = s[i];
				else y = s[i];
			}
		}
		if(x == cup) cup = y;
		if(y == cup) cup = x;
	}
	cout << cup << endl;
	return 0;
}