   program abc162d
      implicit none
      integer::n
      character(len=4000)::s1
      integer::i,j,k,count0=0

         read *,n
         read *,s1

         do i=1,n-2
            do j=i+1,n-1
               do k=j+1,n
                  if (s1(i:i)/=s1(j:j) .and. s1(i:i)/=s1(k:k) &
                                 .and. s1(j:j)/=s1(k:k)) then
                     if ((j-i)/=(k-j)) then
                        count0=count0+1
                     end if
                  end if
               end do
            end do
         end do

         print *,count0

   end program abc162d