n = gets.chomp.to_i
s_arr = readlines.map(&:chomp)

sorted = {}
cnt= 0
n.times do |i|
    now = s_arr[i].chars.sort.join
    if sorted[now] == nil
        sorted[now] = 1
    else
        cnt += sorted[now]
        sorted[now] += 1
    end
end
p cnt