#include <iostream>

using namespace std;

int n, x, y;
bool cor[10][10];

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

    }


    return 0;
}