"use strict";
function main(input) {
  const n = parseInt(input[0]);
  const s = input[1].trim().split("");
  let counter = 0;

  for(let k=0;k<n;k++){
    for(let j=0;j<k;j++){
      for(let i=0;i<j;i++){
        if(((s[i]!==s[j]) && (s[k]!==s[i]) && (s[j]!==s[k]))&&((j-i)!==(k-j))){
          counter++;
        }
      }
    }
  }
  console.log(counter);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));