#include <iostream>

using namespace std;

int n , x[200005] ,y[200005];

int main (){
//  unos
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
    }
//  10 poena:
    if (n == 1){
        cout << 0 << endl;
    }
    else if (n == 2){
        if (x[1] == x[2] or y[1] == y[2]){
            cout << 1 << endl;
        }
        else cout << 0 << endl;
    }
//  20 poena:


    return 0;
}