def signature(word)
  word.chars.sort.join.intern
end

n = gets.chomp.to_i

res = 0
graph = {}
(1..n).each do
  s = gets.chomp
  sig = signature s
  if graph[sig].nil?
    graph[sig] = 0
  else
    res += graph[sig]
  end
  graph[sig] += 1
end

puts res
