n = gets.to_i

s = []
n.times do |i|
  s << gets
end

list = []
n.times do |i|
  list[i]={}
  ("a".."z").each do |j|
    list[i][j]=s[i].count(j)
  end
end

# puts list.uniq

count = 0
n.times do |i|
  (n-i).times do |j|
    if list[i]==list[i+j+1]
      count += 1
    end
  end
end

puts count
# list.uniq.each do |i|
#   puts list.count(i)
# end

