#include <cstdio>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <vector>
#include <stack>
#include <bitset>
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int n,x,y,x2,y2;
int main(){
cin>>n;
cin>>x>>y>>x2>>y2;
if(x==x2 or y==y2)cout<<1<<endl;
else cout<<0<<endl;
return 0;
}