#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int x[n][2];
    for(int i = 0 ; i < n ; i++) {
        cin >> x[i][0] >> x[i][1];
    }
    if(x[0][0] == x[1][0] || x[0][1] == x[1][1]) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}