n = gets.chomp.to_i
s = []
hash = {}

for i in 1..n do
    word = gets.chomp.split("").sort.join
    if hash.key?(word) 
        hash[word] += 1
    else
        hash[word] = 1
    end
end

sum = 0
hash.each{ |key,value| 
    sum += value*(value-1)/2
}
p sum