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

namespace zadatak3
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[,] matriks = null;
            matriks = new int[N,N];

            string[] koordinate = null;
            koordinate = new string[N];

            for (int i=0; i<N;i++)
                koordinate[i] = Console.ReadLine();

            for (int i = 0; i < N; i++)
                for (int j = 0; j < N; j++)
                    matriks[i,j] = 0;

            for (int i = 0; i < N; i++)
            {
                string[] temp = koordinate[i].Split();
                int x = int.Parse(temp[0])-1;
                int y = int.Parse(temp[1])-1;
                matriks[x, y] = 1;
            }

            /*for (int i = 0; i < N; i++)
            {
                Console.WriteLine();
                for (int j = 0; j < N; j++)
                    Console.Write(matriks[i, j]);
            }*/

            int sekundi = 0;

            for (int i = 0; i < N; i++)
                for (int j = 0; j < N; j++)
                {
                    if (matriks[i,j]==1)
                    for (int v = 1; i + v < N; v++)
                    if (matriks[i+ v, j] == 1)
                    { sekundi++; matriks[i, j] = 0; break; }
                    if (matriks[i, j] == 1)
                    for (int v = 1; j + v < N; v++)
                    if (matriks[i, j+v] == 1)
                    { sekundi++; matriks[i, j] = 0; break; }

                    if (matriks[i, j] == 1)
                    for (int v = 1; i - v >= 0; v++)
                    if (matriks[i - v, j] == 1)
                    { sekundi++; matriks[i, j] = 0; break; }
                    if (matriks[i, j] == 1)
                    for (int v = 1; j - v >= 0; v++)
                    if (matriks[i, j - v] == 1)
                    { sekundi++; matriks[i, j] = 0; break; }
                }
           

            Console.WriteLine(sekundi);
            Console.ReadLine();
        }
    }
}