{-# LANGUAGE BangPatterns #-}
module Main where
import Data.Hashable
import qualified Data.Vector as V
import Data.ByteString.Char8 as B
import Data.Monoid
import qualified Data.HashMap.Strict as HM

main = do
  n <- readLn
  let go 0 acc m = print acc
      go n acc m = do
        str <- B.sort <$> B.getLine
        let !acc' = maybe acc (acc+) $ HM.lookup str m
        go (n-1) acc' $! HM.insertWith (+) str 1 m
  go (n :: Int) 0 HM.empty
