n = gets.to_i
words = []
count = 0
n.times do
  words << gets.chomp.chars
end

word_combi = words.combination(2).to_a
word_combi.each do |combi|
  if combi[0].uniq == combi[1].uniq
    count += 1
  end
end

puts count