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

namespace petlja2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<tacka> tacke = new List<tacka>();
            string[] x;
            int br = 0;
            for (int i = 0; i < n; i++)
            {
                x = Console.ReadLine().Split();
                tacka dot = new tacka();
                dot.x = int.Parse(x[0]);
                dot.y = int.Parse(x[1]);
                tacke.Add(dot);
            }
            bool breakic = true;
            tacke.Sort((d, l) => d.x.CompareTo(l.x));
            while (breakic)
            {
                if (tacke.Count == 1)
                    breakic = false;
                for (int i = 0; i < tacke.Count-1; i++)
                {
                    if (tacke[i].x==tacke[i+1].x)
                    {
                        tacke.RemoveAt(boljix(tacke,i,i+1));
                        br++;
                        if (tacke.Count == 1)
                            breakic = false;
                        break;
                    }
                    if (i == tacke.Count - 2)
                        breakic = false;
                }
            }
            breakic = true;
            tacke.Sort((d, l) => d.y.CompareTo(l.y));
            while (breakic)
            {
                if (tacke.Count == 1)
                    breakic = false;
                for (int i = 0; i < tacke.Count - 1; i++)
                {
                    if (tacke[i].y == tacke[i + 1].y)
                    {
                        tacke.RemoveAt(boljiy(tacke,i,i+1));
                        br++;
                        if (tacke.Count == 1)
                            breakic = false;
                        break;
                    }
                    if (i == tacke.Count - 2)
                        breakic = false;
                }
            }
            Console.WriteLine(br);
        }

        static int boljix(List<tacka> tacke, int i, int ip)
        {
            int ii = 1, iip = 1;
            for (int k = 0; k < tacke.Count; k++)
            {
                if (k != i && tacke[k].y == tacke[i].y)
                    ii++;
                if (k != i && tacke[k].y == tacke[ip].y)
                    iip++;
            }
            if (ii >= iip)
                return i;
            else
                return ip;
        }

        static int boljiy(List<tacka> tacke, int i, int ip)
        {
            int ii = 1, iip = 1;
            for (int k = 0; k < tacke.Count; k++)
            {
                if (k != i && tacke[k].x == tacke[i].x)
                    ii++;
                if (k != i && tacke[k].x == tacke[ip].x)
                    iip++;
            }
            if (ii >= iip)
                return i;
            else
                return ip;
        }
        struct tacka
        {
            public int x;
            public int y;
        };
    }
}