n = gets.to_i
s = gets.chomp.chars
sum = 0
arr1 = []
(n - 1).downto(2) do |i|
  next if arr1.include?(s[i])
  arr1 << s[i]
  arr2 = []
  (i - 1).downto(1) do |j|
    next if arr2.include?(s[j])
    arr2 << s[j]
    sum += s[0...j].uniq.size
  end
end
puts sum