import Data.List

main :: IO ()
main = do
  ss <- getParams
  print $ solve ss

getParams :: IO [String]
getParams = tail . lines <$> getContents

solve :: [String] -> Int
solve ss = sum $ map numIJs groups
  where numIJs g = sum [1..length g - 1]
        groups   = group $ sort sorteds
        sorteds  = map sort ss
