n, d = gets.chop.split.map(&:to_i)
x = []
n.times do |i|
  x[i] = gets.chop.split.map(&:to_i)
end

count = 0
n.times do |i|
  nakami = []
  d.times do |j|
    if i == n
      nakami[j] = (x[i][j].to_f - x[i+1][j].to_f) ** 2
    else
      nakami[j] = (x[i][j].to_f - x[0][j].to_f) ** 2
    end
  end
  count += 1 if Math.sqrt(nakami.inject(:+)).to_s =~ /^([1-9][0-9]|[1-9])+.0$/
end

puts count