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

answerarray=Array.new(1000,false)
dparray=Array.new(n).map{Array.new(121,false)}
dparray[0][s[0]+1]=true


(n-1).times{|i|
    number=s[i+1]
    dparray[i+1][number+1]=true
    dparray[i].map.with_index{|value,index|
        if value
            dparray[i+1][index]=true
        end
        
        if value && index<=10
           dparray[i+1][index*11+number+2]=true
        elsif value
            index-=1
            syou=index/11
            amari=index%11
            hyaku=(syou-1)*100
            zyuu=(amari-1)*10
            if amari==0
                zyuu=9
            end
            answerarray[hyaku+zyuu+number-1]=true
        end
    }
}

puts answerarray.count(true)