import Data.List
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Map as Map

type M = Map.Map String Integer

getLines :: IO [String]
getLines = map (sort . BC.unpack) . BC.lines <$> BC.getContents

solve :: [String] -> M -> Integer
solve [] _ = 0
solve (s:ss) m = count + solve ss nextm
  where sorted = sort s
        count = fromMaybe 0 $ Map.lookup sorted m
        nextm = Map.insert sorted (count + 1) m

main :: IO ()
main = do
  getLine
  ls <- getLines
  print $ solve ls Map.empty