let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_string () = Scanf.scanf " %s" (fun x -> x)
let scan_array len read_func = Array.init len (fun _ -> read_func())
let print_int n = Printf.printf "%d\n" n

let () =
  let n = scan_int() in
  let arr = scan_array n scan_string in
  let sort_char s = 
    let a = Array.init (String.length s) (fun i -> s.[i]) in
    let _ = Array.sort compare a in
    let _ = Array.iteri (fun i x -> (s.[i] <- x)) a in s in
  let arr = Array.map sort_char arr in
  let _ = Array.fast_sort compare arr in
  let rec for_loop i st ret =
    if i == n then
      let t = i - st in ret + t * (t-1) / 2
    else
      if arr.(i) <> arr.(i-1) then
        let t = i - st in
        let ret = ret + t * (t-1) / 2 in
        for_loop (i+1) i ret
      else for_loop (i+1) st ret in
  print_int (for_loop 1 0 0)
