import Data.List
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

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

fl = [factorial $ fromIntegral x | x <- [0..]]

factorial :: Integer -> Integer
factorial 0 = 1
factorial 1 = 1
factorial n = n * (fl !! (fromIntegral n - 1))

combies :: Integer -> Integer
combies n
  | n <= 1 = 0
  | n == 2 = 1
  | otherwise = factorial n `div` 2 * factorial (n - 2)

main :: IO ()
main = do
  getLine
  ls <- getLines
  print . sum . map (combies . fromIntegral . length) $ group $ sort ls