#include <iostream>
#include <vector>
#include <algorithm>
#define endl '\n'
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << x << endl;
#define MAXN 200005
using namespace std;

struct point
{
	int x, y;
};

int n;
point figures[MAXN];
/*
bool unique_x[MAXN];
bool unique_y[MAXN];

int NextFreeX(int val)
{
	int res1 = -1;
	int res2 = -1;
	for (int i = val + 1; i < n; i++)
	{
		if (unique_x[i]) { res1 = i; break; }
	}
	for (int i = val - 1; i >= 0; i--)
	{
		if (unique_x[i]) { res2 = i; break; }
	}
	if (res1 == -1 && res2 == -1) return 0;
	if (res1 == -1) return res2;
	if (res2 == -1) return res1;
	return min(res1, res2);
}

int NextFreeY(int val)
{
	int res1 = -1;
	int res2 = -1;
	for (int i = val + 1; i < n; i++)
	{
		if (unique_y[i]) { res1 = i; break; }
	}
	for (int i = val - 1; i >= 0; i--)
	{
		if (unique_y[i]) { res2 = i; break; }
	}
	if (res1 == -1) return res2;
	if (res2 == -1) return res1;
	return min(res1, res2);
}
*/

int main()
{
	cin >> n;
	if (n <= 2)
	{
		int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
		if (x1 == x2 || y1 == y2) cout << "1\n";
		else cout << "0\n";
		return 0;
	}
	/*for (int i = 0; i < n; i++)
		unique_x[i] = true;
	for (int i = 0; i < n; i++)
		unique_y[i] = true;

	if (n <= 7)
	{
		int result = -1;
		for (int i = 0; i < n; i++)
		{
			cin >> figures[i].x >> figures[i].y;
			unique_x[figures[i].x] = 0;
			unique_y[figures[i].y] = 0;
		}
		for (int i = 0; i < n; i++)
		{
			int total = 0;
			vector<point> uniques(n);
			uniques[0] = figures[i];
			point first = uniques[0];
			unique_x[first.x] = 0;
			unique_y[first.y] = 0;
			vector<point> trapped;
			for (int j = 0; j < n; j++)
			{
				if (j == i) continue;
				point curr = figures[j];
				if (unique_x[curr.x] && unique_y[curr.y]) continue;
				if (!unique_x[curr.x])
				{
					int next = NextFreeX(curr.x);
					if (!next) { trapped.push_back(curr); continue; }
					total += abs(curr.x - next);

				}
			}
		}
	}*/
}