require 'set'

N = gets.chomp.to_i

s_c_hash = {}

u_set = Set.new
prev_size = 0

N.times do
  e = gets.chomp.split('').sort!.join('')
  u_set << e
  if prev_size != u_set.size
    s_c_hash[e.to_sym] = 1
    prev_size += 1
  else
    s_c_hash[e.to_sym] += 1
  end
end

ret = 0
if u_set.size != s_c_hash.count
  s_c_hash.to_a.reject! { |_k, v| v == 1 }.each do |_k, v|
    ret += (v * (v - 1)) / 2
  end
else
  s_c_hash.to_a.each do |_k, v|
    ret += (v * (v - 1)) / 2
  end
end

print ret
