open System.Collections.Generic

let inline Σ n = n*(n+1L) / 2L
let inline sort (s:string) = new string (s.ToCharArray() |> Array.sort)
let inline sum (xs:Dictionary<string, int64>) =
    let mutable total = 0L
    for x in xs do
        let N = x.Value
        total <- total + Σ(N-1L)
    total
let inline load n =
    let xs = Dictionary<string, int64>()
    for _ in 0..n-1 do
        let s = stdin.ReadLine() |> sort
        if (xs.ContainsKey s) then
            xs.[s] <- xs.[s] + 1L
        else
            xs.Add (s, 1L)
    xs

let N = stdin.ReadLine() |> int
let xs = load N
printfn "%d" (sum xs)