#include <iostream> 

using namespace std;

int main() {
	int n, x[1000], y[1000], brojac;
	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>x[i]>>y[i];
	}
	if (n == 1) cout<<0;
	else if (n == 2) {
		if (x[0] == x[1] || y[0] == y[1]) cout<<1;
		else cout<<0;
	}
	else {
		cout<<0;
	}
	return 0;
}