n = gets.chomp.to_i
ana = []
n.times do |i|
  ana << gets.chomp
end
ary = []
ana.each do |a|
  b = a.split('')
  h = {}
  b.uniq.each do |s|
    h[s] = b.count{|ss| ss == s }
  end
  ary << h.sort
end
puts ary.group_by{ |e| e }.select { |k, v| v.size > 1 }.map(&:first).count**2