#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
  int n;
  scanf("%d", &n);
  char str[n];
  scanf(" %s", str);

  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if ((j - i) == (k - j)) {
          continue;
        } else if (str[i] != str[j] && str[j] != str[k] && str[i] != str[k]) {
          sum++;
        }
      }
    }
  }

  printf("%lld\n", sum);

  return 0;
}
