n = gets.to_i
s = gets.rstrip

l = Hash.new(0)
r = Hash.new(0)
1.upto(n-1) do |i|
  r[s[i]] += 1
end

d = Array.new(1000, 0)

1.upto(n-2) do |i|
  l[s[i-1]] += 1
  r[s[i]] -= 1

  b = s[i]
  l.each do |a, va|
    r.each do |c, vc|
      if va > 0 && vc > 0
        d[(a + b + c).to_i] = 1
      end
    end
  end
end

p d.reduce(&:+)
