n = gets.chomp.to_i
s = []

for i in 1..n do
    word = gets.chomp.split("")
    s.push(word.sort)
end

s.sort!

sum = 0
tmp = 1
for i in 1..n-1 do
    if s[i-1] == s[i]
        tmp += 1
    else
        sum += tmp*(tmp-1)/2
        tmp = 1
    end
end

sum += tmp*(tmp-1)/2

p sum
