N = gets.to_i
list = []
res = 0
h = {}
N.times do |i|
    s = gets.chomp
    s = s.split('').sort.join()
    if list.include?(s) then
        res += h[s]
        h[s] += 1
    else
        list.push s
        h[s] = 1
    end
end
puts res