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

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

  println(sum)
}
