n = gets.chomp.to_i
hash = {}

def hoge(n)
  result = 0
  n.times do |i|
    result += i
  end
  result
end

n.times do
  s = gets.chomp.split('').sort.join
  hash[s] ? hash[s] += 1 : hash[s] = 1
end
result = 0

hash.each do |k,v|
  if (v > 1)
    result += hoge(v)
  end
end
puts result