program sample
  implicit none
  integer :: n,i,j,k,l,u,v,w
  integer :: m(0:999)
  character(30000) :: s


  read(*,*) n,s
  s=trim(s)
  m=0

  do i=1,n-2
     read(s(i:i),*) u
     do j=i+1,n-1
        read(s(j:j),*) v
        do k=j+1,n
           read(s(k:k),*) w
           l=u*100+v*10+w
           m(l)=1
        enddo
     enddo
  enddo

  write(*,*) sum(m)
           
  stop
end program sample