N=gets.to_i
S=gets.split('').map(&:to_i)

dp=Array.new(N+1){Array.new(4){Array.new(1000,false)}}
dp[0][0][0]=true
N.times do |i|
    4.times do |j|
        1000.times do |k|
            if dp[i][j][k]
                dp[i+1][j][k]=true
                nk = k*10 + S[i]
                next if nk > 999 || j+1 > 3
                dp[i+1][j+1][nk]=true
            end
        end
    end
end


p dp[N][3].group_by(&:itself).map{ |k, v| [k, v.count] }.to_h[true]
