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

sorted_s = s.map { |sn| sn.chars.sort.join }.sort!
counts = sorted_s.uniq.map { |sn| sorted_s.count(sn) } 

answer = counts.map { |n| n * (n - 1) / 2 }

puts answer.inject(:+)
