import qualified Data.ByteString.Char8 as B
import           Data.List
import qualified Data.Map.Strict       as M

main :: IO ()
main = getParams >>= print . solve

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

solve :: [B.ByteString] -> Int
solve = accumulate . build

accumulate :: M.Map B.ByteString Int -> Int
accumulate = M.foldr f 0
  where f x acc = g x + acc
        g x     = x*(x-1) `div` 2

build :: [B.ByteString] -> M.Map B.ByteString Int
build = go M.empty . map B.sort
  where go m []     = m
        go m (s:ss) = go m' ss
          where m' = M.insertWith (+) s 1 m
