module StringMap = Map.Make (struct
  type t = string
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let ss = Array.init n @@ fun _ ->
    Scanf.scanf "%s\n" @@ fun s ->
      let a = Array.init (String.length s) (String.get s) in
      Array.sort compare a;
      String.init (String.length s) (Array.get a) in
  Printf.printf "%d\n" @@
  StringMap.fold (fun _ n acc -> acc + n * (n - 1) / 2)
    (Array.fold_left (fun m s ->
      StringMap.add s
        (1 + try StringMap.find s m with Not_found -> 0) m)
    StringMap.empty ss) 0


