n=gets.to_i
words=[]
n.times do
  word = gets.chomp.split("").sort.join("")
  if words.exist?(word)
    words[word] +=1
  else
    words[word] = 1
  end
end
counter=0
 
words.each_pair do |key,value|
  if value > 1
    counter += value * (value-1) / 2
  end
end
puts counter