
import Control.Monad
import qualified Data.Map as Map

string2map :: String -> Map.Map Char Int
string2map [] = Map.empty
string2map (c:cs) =
  let m = string2map cs
  in
    case Map.lookup c m of
      Nothing -> Map.insert c 1 m
      Just n  -> Map.insert c (n+1) m

isAnagram :: String -> String -> Bool
isAnagram s1 s2 = Map.toAscList (string2map s1) == Map.toAscList (string2map s2)

foo :: [Bool] -> [String] -> [String] -> [String]
foo [] [] acc = acc
foo (b:bs) (s:ss) acc = if not b then s:acc else acc

numOfAnagram :: [String] -> Int
numOfAnagram [] = 0
numOfAnagram [_] = 0
numOfAnagram (x:xs) =
  let
    a = map (isAnagram x) xs
    b = foo a xs []
    num = foldl (\acc x -> if x then acc+1 else acc) 0 a
    ans = num * (num-1) / 2
  in
    ans + numOfAnagram b
  
main = do
  num <- read <$> getLine :: IO Int
  ss  <- replicateM num getLine
  print $ numOfAnagram ss 



