lines = STDIN.readlines.map(&:chomp)
n = lines.shift.to_i

t = {}
c = 0
lines.each do |s|
  if t[s.each_char.sort.join].nil?
    t[s.each_char.sort.join] = 1
  else
    c += t[s.each_char.sort.join]
    t[s.each_char.sort.join] += 1
  end
end

puts c