program D_Lucky_PIN
    implicit none
    integer::n,i,j,k,ans
    character(:),allocatable::str,tmpstr,ttmpstr
    character::array(10) = (/"0","1","2","3","4","5","6","7","8","9"/)
    read*,n
    allocate(character(n)::str)
    read*,str
    ans = 0

    do i = 1,10
        if (index(str,array(i)) > 0) then
            tmpstr = str(index(str,array(i))+1:n)
            do j = 1,10
                if (index(tmpstr,array(j)) > 0) then
                    ttmpstr = str(index(str,array(i))+index(tmpstr,array(j))+1:n)
                    do k = 1,10
                        if (index(ttmpstr,array(k)) > 0) then
                            ans = ans + 1
                        end if
                    end do
                end if
            end do
        end if
    end do

    print*,ans
end program D_Lucky_PIN