open System

let n = Console.ReadLine() |> int

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

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

    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] + 1L)
                else
                    m |> Map.add c 1L
            ) (Map []))
    |> List.countBy id
    |> List.map (fun (m, n) -> (m, int64 n))
    |> List.fold (fun acc (_, n) -> acc + (choose2 n)) 0L

ans |> Console.WriteLine