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

namespace ZLATNICI
{
    class Program
    {
        struct m
        {
            public int x;
            public int y;
        }
        static int m1(m a, m b)
        {
            if (a.x > b.x) return -1;
            else return 1;
        }
        static int m2(m a, m b)
        {
            if (a.y > b.y) return -1;
            else return 1;
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            int[] b = new int[n];
            m[] p = new m[n];
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split();
                a[i] = int.Parse(s[0]);
                b[i] = int.Parse(s[1]);
                p[i].x = a[i];
                p[i].y = b[i];
            }
            Array.Sort(a);
            Array.Sort(b);
            int x = 0, y = 0;
            for (int i = 1; i < n; i++)
            {
                if (a[i - 1] == a[i]) x++;
                if (b[i - 1] == b[i]) y++;
            }
            int z = Math.Max(x, y);
            if (x == 0 && y == 0) z = 0;
            else if (x >= y)
            {
                Array.Sort(p, m1);
                for (int i = 1; i < n - 1; i++)
                {
                    if (p[i - 1].x == p[i].x || p[i + 1].x == p[i].x) p[i].y = 0;
                    else if (i == 1 && p[i].x == p[i - 1].x) p[i - 1].y = 0;
                    else if (i == n - 2 && p[i].x == p[i + 1].x) p[i + 1].y = 0;
                }
                Array.Sort(p, m2);
                for (int i = 1; i < n - x - 1; i++)
                {
                    if (p[i - 1].y == p[i].y || p[i + 1].y == p[i].y) z++;
                    else if (i == 1 && p[i].y == p[i - 1].y) z++;
                    else if (i == n - x - 2 && p[i].y == p[i + 1].y) z++;
                }
            }
            else
            {
                Array.Sort(p, m2);
                for (int i = 1; i < n - 1; i++)
                {
                    if (p[i - 1].y == p[i].y || p[i + 1].y == p[i].y) p[i].x = 0;
                    else if (i == 1 && p[i].y == p[i - 1].y) p[i - 1].x = 0;
                    else if (i == n - 2 && p[i].y == p[i + 1].y) p[i + 1].x = 0;
                }
                Array.Sort(p, m1);
                for (int i = 1; i < n - y - 1; i++)
                {
                    if (p[i - 1].x == p[i].x || p[i + 1].x == p[i].x) z++;
                    else if (i == 1 && p[i].x == p[i - 1].x) z++;
                    else if (i == n - y - 2 && p[i].x == p[i + 1].x) z++;
                }
            }
            Console.WriteLine(z);
        }
    }
}