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

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

    int r[n],c[n];

    unsigned long i;
    for(i=1;i<=n;i++)
        scanf("%d %d",&r[i],&c[i]);

    if(n==1)
        printf("%d",0);
    if(n==2)
    {
        if(r[1]==c[1] && r[2]==c[2])
            printf("%d",0);
        else if(r[1]==c[2] && r[2]==c[1])
            printf("%d",0);
        else
            printf("%d",1);

    }

    return 0;
}