#include<iostream>
using namespace std;
int main(){
	char c1, c2, delim, ball = 'A';
	while(cin >> c1 >> delim >> c2){
		if(ball == c1) ball == c2;
		else if(ball == c2) ball == c1;	
	}
	cout << ans << endl;
}