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

class program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[,] koordinate = new int[n, 2];
        List<int> x = new List<int>();
        List<int> y = new List<int>();
        List<double> d1 = new List<double>();
        List<double> d2 = new List<double>();
        int duzina;
        double duzina2;
        int max;
        int brx=0; int bry=0; int brd2=0; int brd1=0;
        for (int i=0; i<n; i++)
        {
            var s = Console.ReadLine().Split();
            koordinate[i, 0] = int.Parse(s[0]);
            koordinate[i, 1] = int.Parse(s[1]);
        }
        for(int j=0; j<n-1; j++)
        {
            for(int k=j+1; k < n; k++)
            {
                if(koordinate[j,0] == koordinate[k, 0])
                {
                    duzina = Math.Abs(koordinate[j, 1] - koordinate[k, 1]);
                    x.Add(duzina);
                    brx++;
                }
                else if (koordinate[j, 1] == koordinate[k, 1])
                {
                    duzina = Math.Abs(koordinate[j, 0] - koordinate[k, 0]);
                    y.Add(duzina);
                    bry++;
                }
                else if (koordinate[j, 0] + koordinate[j, 1] == koordinate[k, 0] + koordinate[k,1])
                {
                    if (koordinate[k, 1] >= koordinate[j, 1]) { max = koordinate[k, 1]; } else { max = koordinate[j, 1]; }
                    duzina2 = Math.Sqrt(Math.Abs(koordinate[k, 0] - koordinate[j, 0]) * Math.Abs(koordinate[k, 0] - koordinate[j, 0]) + max * max);
                    d1.Add(duzina2);
                    brd1++;
                }
                else if (koordinate[j, 0] - koordinate[j,1] == koordinate[k, 0] - koordinate[k,1])
                {

                    duzina2 = Math.Abs(koordinate[j, 0] - koordinate[k, 0]);
                    if (koordinate[k, 1] >= koordinate[j, 1]) { max = koordinate[k, 1]; } else { max = koordinate[j, 1]; }
                    duzina2 = Math.Sqrt(Math.Abs(koordinate[k, 0] - koordinate[j, 0]) * Math.Abs(koordinate[k, 0] - koordinate[j, 0]) + max * max);
                    d2.Add(duzina2);
                    brd2++;
                }

            }
        }
        int brojac = 0;
        for(int m=0; m<brx-1; m++)
        {
            for(int l=m+1; l<brx; l++)
            {
                if (x[m] * 2 == x[l] || x[l] * 2 == x[m])
                {
                    brojac++;
                }
            }
        }
        for (int m = 0; m < bry - 1; m++)
        {
            for (int l = m + 1; l < bry; l++)
            {
                if (y[m] * 2 == y[l] || y[l] * 2 == y[m])
                {
                    brojac++;
                }
            }
        }
        for (int m = 0; m < brd1 - 1; m++)
        {
            for (int l = m + 1; l < brd1; l++)
            {
                if (d1[m] * 2 == d1[l] || d1[l] * 2 == d1[m])
                {
                    brojac++;
                }
            }
        }
        for (int m = 0; m < brd2 - 1; m++)
        {
            for (int l = m + 1; l < brd2; l++)
            {
                if (d2[m] * 2 == d2[l] || d2[l] * 2 == d2[m])
                {
                    brojac++;
                }
            }
        }
        Console.WriteLine(brojac);
    }
}