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

  var count = 0
  for (Seq(i,j,k) <- s.indices.combinations(3)) {
    if (j-i != k-j && s(i) != s(j) && s(i) != s(k) && s(j) != s(k))
      count += 1
  }
  println(count)
}