#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int main() {
    ios_base::sync_with_stdio(false);

    // Input

    ull n;
    cin >> n;

    int a[n];
    int b[n];

    for (ull i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    // 10-15 poena LOL

    if (n == 1) {
        cout << 0;
    } else if (n == 2) {
        if (a[0] != a[1] && b[0] != b[1])
            cout << 0;
        else {
            cout << 1;
        }
    } else {
        cout << 0;
    }

    return 0;
}