const main = (inputs) => {
  var num = inputs[0] - 0;
  var font = inputs[1];
  var sum = 0;
  var i = 1;
  var k = 2;
  var j = 3;
  var count = 0;


  for (var i = 1; i <= num - 2; i++) {
    for (var j = 2; j <= num - 1; j++) {
      for (var k = 3; k <= num; k++) {
        if (i < j && j < k) {
          sum = sum + check(font, i, j, k);
        }

      }
    }
  }
  console.log(sum);

}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));


function check(font, i, j, k) {
  if (font[i - 1] == font[j - 1] || font[i - 1] == font[k - 1] || font[j - 1] == font[k - 1] || j - i == k - j) {
    return 0;
  } else {
    return 1;
  }
}