#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n, x, y;
	cin >> n;
	vector<pair<int, int> > v;
	
	for (int i = 0; i < n; ++i) {
		cin >> x >> y;
		v.emplace_back(make_pair(x, y));
	}
	
	if (n == 1) {
		cout << 0;
	} else if (n == 2) {
		if (v[0].first == v[1].first || v[0].second == v[1].second) {
			cout << 1;
		} else {
			cout << 0;
		}
	}
}