open System

let n = Console.ReadLine() |> int

let ss =
    [ for i in 1 .. n -> Console.ReadLine() ]

let ans =
    let choose2 n = n * (n - 1) / 2

    let maps =
        ss
        |> List.map (fun s ->
            [0 .. s.Length - 1]
            |> List.map (fun i -> s.[i])
            |> List.fold (fun (m: Map<_, _>) c ->
                if m.ContainsKey c then
                    m |> Map.add c (m.[c] + 1)
                else
                    m |> Map.add c 1
                )
                (Map []))
        |> List.countBy id

    maps
    |> List.fold (fun acc (_, n) -> acc + (choose2 n)) 0

ans |> Console.WriteLine