function Main(input) {
  	input = input.split("\n");
  	i = 0;
  	x = [];
	counter = 0;
   for(i=0;i<input.length;i++){
      	num = input[i].split(" ");
      	littleX = [];
		for(j=0;j<num.length;j++){
          	littleX.push(num[j]);
        }
      	x.push(littleX);
    }

  	for(i=1;i<input.length;i++){
      	for(k=i+1;k<input.length;k++){
	      	//console.log("check "+i+"to"+k);
          	//console.log(x[i]);
          	//console.log(x[k]);
          	sum = 0;
          	for(j=0;j<x[i].length;j++){
            	sum+= (x[i][j] - x[k][j])*(x[i][j] - x[k][j]);
            }
          	//console.log(Math.sqrt(sum));
          	//console.log(Number.isInteger(Math.sqrt(sum)));
          	if(Number.isInteger(Math.sqrt(sum)) === true){
            	counter++;
            }
        }
    }
	console.log(counter);
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));