# 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

$facthash = {}
def fact(n)
  return $facthash[n] if $facthash[n]
  mul = 1
  1.upto(n) do |i|
    mul *= i
  end
  $facthash[n] = mul
end

$ncrhash = {}
def nc2(n)
  return $ncrhash[n] if $ncrhash[n]

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

puts sum
