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

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int   scan; // scanf result
  int   answer; // to output 
  int   n; // to input 
  char *s;

  scan = scanf("%d", &n);
  s = (char *)malloc(sizeof(char) * (n + 1));
  scan = scanf("%s", s);
  answer = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (i < j && j < k) {
          if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
            if ((j - i) != (k - j)) {
              answer += 1;
            }
          }
        }
      }
    }
  }
  printf("%d", answer);
  return (0);
}
