function Main(input) {
  input = input.split("/n");
  let n = input[0].split(" ")[0];
  let 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 - 1, i++) {
    for (var j = i + 1, j <= n, j++) {
      for (var k = 0, k <= d - 1, k++) {
          square = square + ( array[i][d] - array[j][d] ) ^ 2;
      }
      distance.push(square ^ (1/2));
      square = 0;
    }
  }
  var intDistance = distance.filter(function (value){
    return value.isInteger;
  })
  console.log(intDistance.length);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));