n = gets.to_i
s = gets.chomp

num1 = Array.new(10, n+1)
num2 = Array.new(10){Array.new(10, n+1)}
num3 = Array.new(10){Array.new(10){Array.new(10, n+1)}}

(n-1).downto(0) {|i| num1[s[i].to_i] = i}

(n-1).downto(0) do |j|
    10.times do |i|
        num2[i][s[j].to_i] = j if num1[i] < j
    end
end

(n-1).downto(0) do |k|
    10.times do |j|
        10.times do |i|
            num3[i][j][s[k].to_i] = k if num2[i][j] < k
        end
    end
end

puts 1000 - num3.flatten.count(n+1)