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

    read*, n
    allocate(character(n):: s)
    allocate(key(0:9,n))
    key(:,:) = .false.
    read*, s
    key(ichar(s(n:n))-ichar('0'),n) = .true.
    do i=n-1,1,-1
        key(:,i) = key(:,i+1)
        key(ichar(s(i:i))-ichar('0'),i) = .true.
    end do
    num(:) = .false.
    do i=1,n-2
        si = ichar(s(i:i))-ichar('0')
        do j=i+1,n-1
            sj = ichar(s(j:j))-ichar('0')
            do k=0,9
                if (.not.key(k,j+1)) cycle
                num(100*si+10*sj+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