n = gets.chomp.to_i
ss = n.times.map { gets.chomp }

dict = {}
ss.each do |s|
  key = s.chars.sort.join
  dict[key] = (dict[key] || 0) + 1
end

cnt = 0
dict.each do |k, v|
  next if v <= 1
  cnt += (v * (v - 1)) / 2
end

puts cnt
