n = gets.to_i

m = {}
n.times do
  s = gets.chomp.split('').sort.join
  if m.include?(s)
    m[s] += 1
  else
    m[s] = 1
  end
end

count = 0
m.each do |key, value|
  count += value * (value - 1) / 2
end

puts count