#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n==2)
    {
        int r;
        int i1,j1,i2,j2;
        cin >> i1 >> j1;
        cin >> i2 >> j2;
        if(i1 != i2 && j1 != j2)
            r=0;
        else
            r=1;
        cout << r;
    }
    else
        cout << "0";
    return 0;
}