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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[,] mat = new int[N, N];
            for (int i = 0; i < N; i++)
            {
                string[] niz = Console.ReadLine().Split();
                mat[int.Parse(niz[0]) - 1, int.Parse(niz[1]) - 1]=2;
            }
            int n = 0;
            for (int i = 0; i < mat.GetLength(0); i++)
            {
                if (provera_X(mat, i) == false || provera_Y(mat, i)==false)
                {
                    n++;
                }
            }
            Console.WriteLine(n);
        }
        static bool provera_X(int[,] mat,int i)
        {
                for (int j = 0; j < mat.GetLength(1); j++)
                {
                    if (mat[i, j] == 2)
                        return true;
                }
                return false;
        }
        static bool provera_Y(int[,] mat, int i)
        {
            for (int j = 0; j < mat.GetLength(1); j++)
            {
                if (mat[j, i] == 2)
                    return true;
            }
            return false;
        }
    }
}