import scala.io.StdIn._
object Main extends App{
  val N = readLine().toInt
  val S = readLine()

  var sum = 0
  (0 until N-2).foreach(i => {
    (i+1 until N-1).foreach(j => {
      (j+1 until N).foreach(k => {
        val si = S(i)
        if((si != S(j)) && (S(i) != S(k)) && (S(j) != S(k)) && ((j-i) != (k-j))){
          sum = sum + 1
        }
      })
    })
  })

  println(sum)
}
