N = gets.chomp.to_i
T = gets.chomp
S = Array.new(N)
for i in 0...N do
    S[i] = T[i].to_i
end
a = Array.new(10,-1)
b = Array.new(10){Array.new(10,-1)}
c = Array.new(10)
answer = 0
for i in 0..9 do
    for j in 3..N do
        s = S[-j]
        a[s] = j-1
    end
end
for i in 0..9 do
   if a[i] >= 0
       for j in 2..a[i] do
        s = S[-j]
        b[i][s] = j-1
       end
   end 
end
for i in 0..9 do
    for j in 0..9 do
        if b[i][j] >= 0
            for k in 0..9 do
                c[k] = 0
            end
            for k in 1..b[i][j] do
                s = S[-k]
                c[s] += 1
            end
            for k in 0..9 do
                if c[k] > 0
                    answer += 1
                end
            end
        end
    end
end
puts answer