open Scanf
open Printf

let stoa s = Array.init (String.length s) (String.get s)

module CharArray = struct
  type t = char array
  let compare = compare
end

module CMap = Map.Make(CharArray)

let () =
  let n = scanf " %d" (fun a -> a) in
  Array.init n (fun _ -> scanf " %s" (fun a -> a))
  |> Array.fold_left (fun (ans, mp) s ->
    let s = stoa s in
    Array.sort compare s;
    if not (CMap.mem s mp) then
      (ans, CMap.add s 1 mp)
    else let x = CMap.find s mp in
      (ans + x, CMap.add s (x + 1) mp)) (0, CMap.empty)
  |> fst
  |> printf "%d\n";
