n = gets.chomp.to_i
arr = Array.new(n).map{Array.new(26,0)}
n.times do |i|
	s = gets.chomp
	s.chars.each do |c|
		arr[i][c.ord - "a".ord] += 1
	end
end
cnt = 0
hash = {}
arr.each do |a|
	if hash.has_key?(a)
		cnt += hash[a]
		hash[a] += 1
	else
		hash[a] = 1
	end
end
puts cnt

