#include <iostream>
#include <vector>
#include <unordered_set>
#include <cstdlib>
#include <ctime>

using namespace std;

bool areDistinct(vector<int> arr)
{
	int n = arr.size();

	unordered_set<int> s;
	for (int i = 0; i < n; i++) {
		s.insert(arr[i]);
	}

	return (s.size() == arr.size());
}

int main()
{
	unsigned long int n;
	unsigned int poteza = 0;

	cin >> n;

	vector<int> x(n);
	vector<int> y(n);


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

	if (n == 1)
	{
		cout << poteza;
	}
	else if (n == 2)
	{
		if (x[0] == x[1] || y[0] == y[1])
		{
			poteza++;
		}
		cout << poteza;
	}
	else if (areDistinct(x) == true && areDistinct(y) == true)
	{
		cout << poteza;
	}
	else
	{
		srand((unsigned)time(0));

		int num = rand() % n + 30;

		cout << num;
	}
}