n = gets.to_i
hash = Hash.new
count = 0;
n.times do |i|
  key = gets.split('').sort.join
  if !hash.key?(key) then
    hash[key] = 1
  else
    count += hash[key]
    hash[key] += 1
  end
end

puts count
