'use strict'

const main = input => {
	const args = input.trim().split('\n')
	const x = []
	let cnt = 0

	for (let i = 1; i < args.length; i++) {
		x.push(args[i].split(' ').map(Number))
	}

	for (let i = 0; i < x.length; i++) {
		for (let j = 0; j < x.length; j++) {
			if (i >= j) continue

			let sum = 0

			for (let k = 0; k < x[i].length; k++) {
				sum += Math.pow(x[i][k] - x[j][k], 2)
			}

			if (Math.sqrt(sum) % 1 === 0) cnt++
		}
	}

	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
