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, n-1
        do k = j, n
           if (s(i:i) /= s(j:j) .and. s(k:k) /= s(j:j) .and. s(i:i) /= s(k:k) &
                & .and. j-i /= k-j) then
              ans = ans + 1
           end if
        end do
     end do
  end do

  print *, ans
  
  stop
end program main
