program sumitrust2019d
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,ans,j,k,ind,si
    integer(int64), allocatable:: cnt(:,:)
    character(:),allocatable:: s
    logical:: num(0:999)

    read*, n
    allocate(character(n):: s)
    allocate(cnt(0:9,n))
    read*, s
    cnt(:,:) = 0
    do i=n-1,1,-1
        cnt(:,i) = cnt(:,i+1)
        cnt(ichar(s(i+1:i+1))-ichar('0'),i) = i+1
    end do

    num(:) = .false.
    do i=1,n-2
        si = ichar(s(i:i)) - ichar('0')
        do j=0,9
            ind = cnt(j,i)
            if (ind == 0) cycle
            do k=0,9
                if (cnt(k,ind) == 0) cycle
                num(100*si+10*j+k) = .true.
            end do
        end do
    end do

    ans=0
    do i=0,999
        if (num(i)) ans=ans+1
    end do
    print'(i0)', ans
end program sumitrust2019d