n = (link: http://gets.to) gets.to_i
strs = []
n.times { strs << gets.chomp }
 
checks = []
strs.each do |str|
  checks << str.chars.sort.join('')
end
 
checks = (link: http://checks.group) checks.group_by { |i| i }.values
 
num = 0
checks.each do |check|
  num += check.size*(check.size-1)/2
end
 
p num