#include <bits/stdc++.h>

using namespace std;

int niz[200005];

int main()
{
    int n;
    cin>>n;
    for(int i = 1;i<=2*n;i+=2)
    {
        cin>>niz[i]>>niz[i+1];
    }

    if(n==2)
    {
        if(niz[1]==niz[3] || niz[2] == niz[4] )
        {
            cout<<1;
            return 0;
        }

        cout<<0;
        return 0;
    }
    
    cout<<0;

    return 0;
}