function main(input) {
  const points = input.slice(1).map(x => x.split(' ').map(Number));

  var sum = 0;
  for (var i = 0; i < points.length; i++) {
    for (var j = i+1; j < points.length; j++) {
	  var len = length(sub(points[i], points[j]));
      if (isInteger(len)) {
        sum++;
      }
    }
  }

  console.log(sum);
}

const sub = (p1, p2) => {
  return p1.map((x, i) => x - p2[i]);
};

const length = (p) => {
  return Math.sqrt(p.map(x => x*x).reduce((acc, x) => acc + x, 0));
};

const isInteger = (n) => {
  const i = Math.floor(n);
  const eps = 0.0000001;

  return n-i < eps;
};

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n'));
