function Main(input) {
  input = input.split("\n");
  const n = input[0].split(" ")[0];
  const d = input[0].split(" ")[1];
  var array = [];
  for (var i = 1; i <= n; i++) {
    array.push(input[i].split(" "));
  }
  
  

  var square = 0;
  var distance = [];
  for (var i = 0; i <= n - 2; i++) {
    for (var j = i + 1; j <= n - 1; j++) {
      for (var k = 0; k <= d - 1; k++) {
          square = square + Math.pow(( array[i][k] - array[j][k] ), 2);
      }
      distance.push(Math.pow(square, 1/2));
      square = 0;      
    }
  }

  var intDistance = distance.filter(function(value){
    return Number.isInteger(value);
  })
  console.log(intDistance.length);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));