program ABC162_D
  character(4000)::S
  read(5,*)N
  read(5,*)S
  L=0
  do I=1,N-3
     do J=I+1,N-1
        do K=J+1,N
           if(S(I:I)/=S(J:J)) then
              if(S(J:J)/=S(K:K) .and. S(I:I)/=S(K:K)) then
                 if(J-I/=K-J) L=L+1
              end if
           end if
        end do
     end do
  end do
  write(6,*)L
end program ABC162_D