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

n = gets.chomp.to_i

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

res = 0
graph.each do |g|
  res += g[1] * (g[1]-1) / 2
end

puts res
