#!/usr/bin/env ruby
n, = ARGF.gets.split.map {|x| x.to_i}
s = (1..n).map do
  table = Array.new
  ARGF.gets.chomp.each_codepoint do |ch|
    if table[ch]
      table[ch] += 1
    else
      table[ch] = 1
    end
  end
  str = ""
  (0..table.size).map do |index| 
    if table[index]
      str += "#{index}:#{table[index]},"
    end
  end
  str
end
sum = 0
while s1 = s.pop
  len1 = s.length
  s.delete(s1)
  len2 = s.length
  count = len1 - len2
  sum += (count + 1) * count / 2
end
puts sum
