#include<bits/stdc++.h>
#define lim 105

using namespace std;

int main(){
	
	int n;
	cin>>n;
	int r[lim];
	int c[lim];
	for(int i=0;i<n;i++){
		cin>>r[i]>>c[i];
	}
	if(n==1){
		cout<<0;
		return 0;
	}
	if(r[0]==r[1]||c[0]==c[1]){
		cout<<1;
	}else{
		cout<<0;
	}
	
}