using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int [,]a=new int[n+1,n+1];
            for (int i = 1; i <= n; i++)
            {
               string []s= Console.ReadLine().Split(' ');
                a[Convert.ToInt32(s[0]),Convert.ToInt32(s[1])] =1 ;
            }
            if (n == 2)
            {
                if (a[1, 2] == 1 && a[2, 1] == 1)
                    Console.WriteLine(0);
                else if(a[1,1]==1&&a[2,2]==1)
                    Console.WriteLine(0);
                else Console.WriteLine(1);
            }
            Console.ReadLine();
        }
    }
}