#include <bits/stdc++.h>
using namespace std;
int n;
int a,b,c,d;
int main (){
cin >> n;
cin >> a >> b >> c >> d;
if (a==c){
    cout << 1 << endl;
}
else if (b==d){
    cout << 1 << endl;
}
    else cout << 0 << endl;

return 0;
}