#include<iostream>

using namespace std;

int main(){
	int A,B,C,x,y,s,t,u;
	A=1,B=2,C=3;
	while(cin>>x","y){
		if((x==A && y==B)||(x==B && y==A)){
			s=A;
			A=B;
			B=z;
		}else if((x==B && y==C)||(x==C && y==B)){
			t=B;
			B=C;
			C=t;
		}else if((x==C && y==A)||(x==A && y==C)){
			u=C;
			C=A;
			A=u;
		}
	}
	if(A==1){A=A}
	else if(A==2){A=B}
	else if(A==3){A=C};
	cout << A << endl;
}
			
