open System.Collections.Generic

let sortString (str:string) = new string (Array.sort (str.ToCharArray()))
let sumTotal N = N*(N-1L)/2L
let cnt = int(stdin.ReadLine())
let xs = Dictionary<string, int64>()
for _ in 0..cnt-1 do
    let s = sortString (stdin.ReadLine ())
    if (xs.ContainsKey s) then
        xs.[s] <- xs.[s] + 1L
    else
        xs.Add (s, 1L)

let mutable sum = 0L
for x in xs do
    let N = x.Value
    sum <- sum + sumTotal N

printfn "%d" sum