fline = readlines
len = fline.length
i = 0
 
while i < len
  fline[i] = fline[i].chomp
  i += 1
end
 
n = 1
counter = 0
 
while n < fline[0].to_i
m = 1
  while n + m <= fline[0].to_i
    a = fline[n].to_r * fline[n + m].to_r
    if a == a.to_i
      counter += 1
    end
    m += 1
  end
n += 1
end
 
p counter