program sample
  implicit none
  integer :: n,i,j,num100,num10,num1,p1,p2,p3,ans
  character(:),allocatable :: s
  character(1) :: ch(0:9)

  read(*,*) n
  allocate(character(n) :: s)
  read(*,*) s
  ch=['0','1','2','3','4','5','6','7','8','9']
  p1=0
  p2=0
  p3=0
  ans=0
  
  do i=0,999
     num100=i/100
     num10=(i-num100*100)/10
     num1=i-num100*100-num10*10
        p1=index(s(1:n),ch(num100))
        if(p1==0.or.p1==n)then
           cycle
        else
           p2=index(s(p1+1:n),ch(num10))
           if(p2==0)then
              cycle
           else
              p2=p2+p1
              if(p2==n)then
                 cycle
              endif
              p3=index(s(p2+1:n),ch(num1))
              if(p3==0)then
                 cycle
              else
                 ans=ans+1
              endif
           endif
        endif
     enddo     

  write(*,*) ans
           
  stop
end program sample
