##题目08
##题解08
import java.math.BigInteger;
import java.util.Scanner;
public class Main08{
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int [][] a =new int[n][2];
int [] t = new int [n];
for(int i=0;i<n;i++) {
a[i][0]=in.nextInt();
a[i][1]=in.nextInt();
t[i]=a[i][0]-a[i][1];
}
//BigInteger count = BigInteger.valueOf(0);
long count = 0;
for(int i=0;i<n;i++) {
for(int j=i+1;j<n;j++) {
if(t[i]+t[j]==0)
//count=count.add(BigInteger.ONE);
count++;
}
}
System.out.println(count);
}
}