table = {}
count = 0

gets.to_i.times do
  word = gets.chomp.chars.sort.join
  if table.keys.include?(word)
    table[word] += 1
    count += table[word]
  else
    table[word] = 0
  end
end
puts count