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

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

count = -n
checks.each do |check|
  count += checks.count(check)
end

puts count/2