#include<iostream>
#include<vector>
//duzi moraju da budu 0 ,45,90,135 stepeni(brhuhuhuhuhhhuhuhuhuuhhuhuhh)
using namespace std;


class duz{
public :int smer;
public :int duzina;
public :duz(int a,int b){smer=a;duzina=b;
}
};
int main(){
int n;
cin>>n;
pair<int,int> takmicar[n];
int m=0;

while (m<n){
cin>>takmicar[m].first;
cin>>takmicar[m].second;
m++;
}
int i=0,j=0;int g;
vector<duz> duzi;
while(i<n){
j=i+1;
while(j<n){
if(takmicar[i].first==takmicar[j].first){duzi.push_back(duz(0,abs(takmicar[i].second-takmicar[j].second)));}
if(takmicar[i].second==takmicar[j].second){duzi.push_back(duz(2,abs(takmicar[i].first-takmicar[j].first)));}
if(takmicar[i].first-takmicar[j].first==takmicar[i].second-takmicar[j].second)
{if(takmicar[i].first>takmicar[j].first&&takmicar[j].second>takmicar[i].second||takmicar[j].first>takmicar[i].first&&takmicar[i].second>takmicar[j].second)g=2;else g=0;duzi.push_back(duz(1+g,abs(takmicar[i].first-takmicar[j].first)));}

j++;
}
i++;
}
i=0;j=0;int k;
while(i<duzi.size())
{j=0;
while(j<duzi.size()){
if(duzi.at(i).smer==duzi.at(j).smer && duzi.at(i).duzina==2*duzi.at(j).duzina)k++;

j++;
}
i++;
}
cout<<k;








}