#include <iostream>

using namespace std;

int main()
{
	unsigned long int n;
	unsigned int x[10];
	unsigned int y[10];
	unsigned long long int arr[10][10];
	int poteza = 0;


	cin >> n;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			arr[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
		arr[x[i]-1][y[i]-1] = 1;
	}

	if (n == 1)
	{
		cout << poteza;
	}
	else if (n == 2)
	{
		if (x[0] == x[1] || y[0] == y[1])
		{
			poteza++;
		}
		cout << poteza;
	}
	else
	{

	}
}