#include <iostream>

using namespace std;

int main()
{   int n,t;
    cin>>n;
    int c1,c2,r1,r2;
    cin>>c1>>r1>>c2>>r2;
    if(r1==r2||c1==c2) t=1;
    else t=0;

    cout << t << endl;
    return 0;
}