#require 'pp'

ans = []
(0..9).each do |i|
  (0..9).each do |j|
    (0..9).each do |k|
      ans << [i, j, k]
    end
  end
end

n = gets.chomp!.to_i
s = gets.chomp!

x = s.chars.group_by {|x| x }.map {|k, v| [k.to_i,v.length] }.to_h

memo = [
  {},{},{},{},{},{},{},{},{},{},
]

s.chars.each_with_index do |ch, index|
  memo[ch.to_i][index] = true
end

count = 0

ans.each do |a,b,c|
  if memo[a].length > 0 && memo[b].length > 0 && memo[c].length > 0
    index = memo[a].first[0]
    index3 = memo[c].keys[-1]
    if index >= index3
      next
    end

    x = nil
    ((index + 1)...index3).each do |t|
      if memo[b][t]
        x = t 
      end
    end

    if x
      index2 = x
    else
      next
    end

    if index < index2 && index2 < index3
      #puts "#{a}#{b}#{c}"
      count += 1
    end
  end
end

puts count
