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

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