let rec same cnt lst =
    match lst with
    | [] -> cnt
    | [x] -> same cnt []
    | x :: tail -> same (cnt + (List.sumBy (fun y -> if x = y then 1 else 0) tail)) tail

let n = stdin.ReadLine() |> int
[for i in 1..n do yield stdin.ReadLine() |> Seq.sort |> Seq.map string |> String.concat ""]
|> Seq.toList
|> same 0
|> printfn "%d"
