#include <bits/stdc++.h>
using namespace std;

vector<int> prvi;
vector<int> drugi;

int main()
{
    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;

        prvi.push_back(a);
        drugi.push_back(b);
    }

    if (n == 1)
    {
        cout << "0" << endl;
    }
    else if (n == 2)
    {
        if (prvi[0] != prvi[1] && drugi[0] != drugi[1]) cout << "0" << endl;
        else cout << "1" << endl;
    }
    else cout << "0" << endl;

    return 0;
}