n = gets.to_i
s = gets.chomp.split("").map(&:to_i)
count = 0
10.times do |i1|
  pos1 = s[0..n-1].index(i1)
  next if pos1 == nil || pos1 == n - 1
  10.times do |i2|
    pos2 = s[(pos1+1)..n-1].index(i2)
    next if pos2 == nil || pos2 == n - 1
    pos2 += pos1 + 1
    10.times do |i3|
      count += 1 if s[(pos2+1)..n-1].index(i3) != nil 
    end
  end
end
puts count
