N = gets.chomp.to_i

S = []
N.times do |i|
  S[i] = gets.chomp.to_s
end

sorted_strings = S.map do |s|
  s.split('').sort.join('')
end

h = sorted_strings.group_by{|s| s}.select{|_, v| v.size > 1}
@output = 0
h.each do |k, v|
  v_size = v.size
  @output += ((v_size * (v_size - 1)) / 2)
end

puts @output

