n = gets.to_i
hash = Hash.new { |h, k| h[k] = [] }

n.times do |i|
  key = gets.chomp.chars.sort.join
  hash[key] << i
end

puts hash.values.inject(0) { |sum, array| sum += array.combination(2).count }
