#include <stdio.h>
#include <stdlib.h>

int main()
{
    unsigned long n;
    scanf("%lu",&n);

    unsigned long kotomb[n][n];
    unsigned long i,j;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=2;j++)
            scanf("%lu",&kotomb[i][j]);
    }

    if(n==2)
    {
        if(kotomb[1][2]==kotomb[2][2] || kotomb[1][1]==kotomb[2][1] || kotomb[1][1]==kotomb[1][2] || kotomb[2][1]==kotomb[2][2])
            printf("%d",1);

        else
            printf("%d",0);
    }

    return 0;
}