open Hashtbl
let n = read_int ()
let f g s = let a = String.(Array.init (length s) @@ get s) in Array.(sort g a; String.init (length a) @@ get a)
let ss = Array.init n @@ fun _ -> f compare @@ read_line ()
let h = create n
let _ = Array.iter (fun s -> replace h s @@ try find h s + 1 with _ -> 1) ss; fold (fun _ c a -> a + c * (c - 1) / 2) h 0 |> Printf.printf "%d\n"