n = gets.to_i
strs = []
n.times { strs << gets.chomp }

checks = []
strs.each do |str|
  checks << str.chars.sort.join('')
end

checks = checks.group_by { |i| i }.values

count = 0
checks.each do |check|
  count += check.size*(check.size-1)/2
end

puts count