import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt()
  sc.nextLine()
  val S = sc.nextLine()

  var x = 0
  for (i <- 1 to N) {
    for (j <- i to N) {
      for (k <- j to N) {
        val Si = S.charAt(i - 1)
        val Sj = S.charAt(j - 1)
        val Sk = S.charAt(k - 1)
        if (Si != Sj && Si != Sk && Sj != Sk && (j - i) != (k - j)) x += 1
      }
    }
  }

  println(x)
}