# frozen_string_literal: true

n = gets.to_i
s = n.times.map { gets.chomp.chars.sort }

h = Hash.new { 0 }

s.each do |e|
  h[e] += 1
end

sum = 0
h.each do |k, v|
  sum += (v * (v - 1) / 2) if v > 1
end

puts sum
