import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.ByteString.Char8 as BS8
 
sol s
    | length s <= 1 = 0
    | otherwise = match + sol ts
    where
        hs = head s
        ts = tail s
        match = length $ filter (hs ==) ts
 
main :: IO ()
main = do
    n <- fst . fromJust . BS8.readInt <$> BS8.getLine
    s <- replicateM n $ ((T.pack).sort)<$>getLine
 
    print $ sol s
