n = gets.chomp.to_i
ana = []
n.times do |i|
  ana << gets.chomp.split('').group_by(&:itself).map{|key, value| [key, value.count] }.to_h.sort
end
puts ana.group_by{ |e| e }.select { |k, v| v.size > 1 }.map(&:first).count**2