n = gets.to_i
s = gets.split(//).map &:to_i

a = [nil] * 10
b = [nil] * 100
c = [nil] * 1000

s.each do |m|
  100.times do |i|
    next unless b[i]
    c[i * 10 + m] = true
  end
  10.times do |i|
    next unless a[i]
    b[i * 10 + m] = true
  end
  a[m] = true
end
puts c.count(&:itself)