n = $stdin.gets.to_i
array = (1..n).map { $stdin.gets }
array = array.map{|s|s.chars.sort.join}
map = array.inject(Hash.new(0)) {|h, e| h.tap {|h| h[e] += 1} }

sum = 0
map.each_pair do |s, cnt|
  sum += (1..(cnt-1)).sum
end
puts sum
