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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    /////////////////////////////////

    int n;
    cin >> n;
    if (n==2){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        if (a!=c && b!=d){
            cout << "0" << endl;
            return 0;
        }
        if (a==c && b!=d){
            cout << "1" << endl;
            return 0;
        }
        if (a!=c && b==d){
            cout << "1" << endl;
            return 0;
        }
        if (a!=c && b==d){
            cout << "1" << endl;
            return 0;
        }
    }
    if (n>2){
        for (int i=0;i<n;i++){
        int e,f;
        cin >> e >> f;
    }
        cout << "0" << endl;
    }

	return 0;
}