program main
  
  implicit none
  integer :: n, i, j, k, ans
  character(4000) :: s
  
  read(*,*) n
  read(*,*) s
  
  ans = 0
  do i = 1, n-2
    do j = i+1, n-1
      do k = j+1, n
        if( s(i:i) /= s(j:j) .and. s(i:i) /= s(k:k) &
           .and. s(j:j) /= s(k:k) .and. j-i /= k-j) then
          ans = ans + 1
        end if
      end do
    end do
  end do
   
  print*, ans 

end program main
