N = gets.to_i
strs = []
N.times do
  strs << gets.chomp.split('').sort
end

checks = strs.group_by { |i| i }.values
count = 0
checks.each do |check|
  count += check.size*(check.size-1)/2
end
 
puts count