N = gets.to_i

hash = Hash.new(0)

N.times do
  d = gets.chomp.chars.sort.join('')
  hash[d] += 1
end

def combi(n, k)
  k = n - k if 2 * k > n
  return 1 if k == 0
  ((n - k + 1)..n).reduce(&:*) / ((1..k).reduce(&:*))
end

result = 0
hash.each do |_k, v|
  next if v <= 1
  result += combi(v, 2)
end
p result
