n = gets.chomp.to_i
slist = []
result = []
n.times do |ni|
  s = gets.chomp
  hash = Hash.new(0)
  s.each_char do |si|
    hash[si] += 1
  end
  slist.push(hash)
end
result = 0
n.times do |ni|
  (ni+1).upto(n-1) do |nii|
    if slist[ni] == slist[nii]
      result += 1
    end
  end
end

puts result
