
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)

numOfAnagram :: [String] -> Int
numOfAnagram [] = 0
numOfAnagram [_] = 0
numOfAnagram (x:xs) = numOfAnagram xs + foldl (\acc a -> if a then acc+1 else acc) 0 (map (isAnagram x) xs)

main = do
  num <- read <$> getLine :: IO Int
  ss  <- replicateM num getLine
  print $ numOfAnagram ss 



