import Data.List
import Control.Monad

dist2 :: [Int] -> [Int] -> Int
dist2 xs ys = sum $  zipWith (\x y -> (x-y)^2) xs ys

isGood :: Int -> Bool
isGood n = (floor x)^2 == n
  where x = sqrt $ fromIntegral n

foo :: [[Int]] -> [[Int]] -> [([Int],[Int])]
foo as bs = do
  a <- as
  b <- bs
  guard (a /= b && isGood (dist2 a b))
  return (a,b)

main = do
  _ <- getLine
  as <- map (map read . words) . lines <$> getContents :: IO [[Int]]
  print . length $ foo as as

