# 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

def fact(n)
  mul = 1
  1.upto(n) do |i|
    mul *= i
  end
  mul
end

$ncrhash = {}
def ncr(n, r)
  return $ncrhash[[n, r]] if $ncrhash[[n, r]]

  $ncrhash[[n, r]] = fact(n) / (fact(n-r) * fact(r))
end
sum = 0
h.each do |k, v|
  sum += ncr(v, 2) if v > 1
end

puts sum
