n, d = gets.split.map(&:to_i)
points = n.times.map do
  gets.split.map(&:to_i)
end

require 'prime'

ans = points.combination(2).map do |x, y|
  x.zip(y).map {|i, j| (i-j)**2 }.inject(:+).prime_division.map(&:last).all?(&:even?)
end.count(true)

puts ans
