$kaiwa_memo = {}
def kaiwa(n)
  return $kaiwa_memo[n] if $kaiwa_memo.has_key?(n)
  return 0 if n == 0
  $kaiwa_memo[n] = n + kaiwa(n - 1)
  $kaiwa_memo[n]
end

N = gets.to_i
S = N.times.map { gets.chomp }

S_ = S.map { |s| s.chars.sort.join }.group_by(&:itself).values.map { |v| kaiwa(v.length - 1) }.reduce(:+)
 
puts S_
