object Main extends App {
  val n = io.StdIn.readInt()
  val s = io.StdIn.readLine()

  var count = 0
  for (i <- 0 until n-2)
    for (j <- i until n-1)
      for (k <- j until n) {
        if (j-i != k-j && s(i) != s(j) && s(i) != s(k) && s(j) != s(k))
          count += 1
      }

  println(count)
}