n = gets.to_i
ss = n.times.map { gets.strip.chars.sort.join('') }
h = {}
ss.each do |s|
  if h[s]
    a, b = h[s]
    h[s] = [a + b, b + 1]
  else
    h[s] = [0, 1]
  end
end

puts(h.values.map(&:first).sum)
