N = gets.chomp.to_i

words = {}
N.times do
  word = gets.chomp.chars.sort.join
  words[word] = words.key?(word) ? words[word] + 1 : 1
end

p words
puts words.values.reduce(0) { |sum, count| count == 2 ? sum + 1 : count == 1 ? sum : sum + count*(count-1)/2 }
