
import Data.List
import Control.Monad

main :: IO ()
main = do
    n <- readLn :: IO Int
    ss <- sort <$> map sort <$> replicateM n getLine :: IO [String]
    print (sum $ map (s . length) $ group ss)


s 1 = 0
s n = s (n - 1) + (n - 1)

