import Foundation


func solve(_ i: Int, _ j: Int, _ k: Int, _ str: String) -> Int {
  
  if i >= j || j >= k || i >= k{
    return 0
  }
  
  var si = str[str.index(str.startIndex, offsetBy: i)]
  var sj = str[str.index(str.startIndex, offsetBy: j)]
  var sk = str[str.index(str.startIndex, offsetBy: k)]

  if si == sj || sj == sk || si == sk {
    return 0
  } else if j - i == k - j {
    return 0
  } else {
    return 1
  }
}


 
let inputLine: String = readLine()!
let inputLine2: String = readLine()!
 
let n: Int = Int(inputLine)!
let s: String = inputLine2

var ans = 0

let a = 0
let b = 0
let c = 0

for a in 1..<n {
  for b in 1..<n {
    for c in 1..<n {
      ans += solve(a, b, c, s)
    }
  }
}

print(ans)

