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

namespace Zlatnici
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int brojac = 0;
            int[,] a = new int[n, n];
            for (int i = 0; i < n; i++)
            {
                string[] str = Console.ReadLine().Split();
                int x = int.Parse(str[0]);
                int y = int.Parse(str[1]);
                a[--x, --y] = 1;
            }
            if (n==2)
            {
                if (a[0, 0] == 1 && a[0, 1] == 1) brojac++;
                else if (a[0, 0] == 1 && a[1, 0] == 1) brojac++;
                else if (a[1, 1] == 1 && (a[1, 0] == 1 || a[0, 1] == 1)) brojac++;
            }
            else if(n==3)
            {
                brojac = 3;
            }
            Console.WriteLine(brojac);
        }
    }
}