n = gets.to_i

list = []
n.times do
  list.sort!
  input = gets.chomp.chars.sort.join
  target = list.find { |s| s[0] == input }
  if target.nil?
    list << [input, 1]
  else
    target[1] += 1
  end
end
puts list.inject(0) { |sum, x| sum + (x[1] - 1) * x[1] / 2 }
