let rec count ss n =
    let rec loop ss s n =
        match ss with
        | [] -> (n, [])
        | s' :: ss' ->
            if s' = s then loop ss' s (n + 1)
            else (n, ss)
    in
    match ss with
    | [] -> n
    | s' :: ss' ->
        let (n', ss'') = loop ss' s' 1 in
        count ss'' (n + n' * (n' - 1) / 2)

let solve ss =
    let ss' = List.map (List.sort compare) ss |> (List.sort compare) in
    count ss' 0

let rec input n =
    if n = 0 then []
    else let line = read_line () in
        Str.split (Str.regexp "") line :: input (n - 1)

let () =
    let n = read_line () |> int_of_string in
    let ss = input n in
    print_int @@ solve ss;
    print_newline ()
