#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a,b,c,d;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    else{
        if(a==c||b==d){
            cout<<1<<endl;
        }
        else{
            cout<<0<<endl;
        }
    }
    return 0;
}