#include <stdio.h>

int main(void)
{

  int n;
  char s[4000];
  int i, j, k, count=0;

  scanf("%d", &n);
    scanf("%s", s);

  /**/
  for (k = 0; k < n; k++) {
    for (j = 0; j < k; j++) {
      for (i = 0; i < j; i++) {
	if ((k - j) != (j - i)) {
	  if (s[k] != s[j] && s[j] != s[i] && s[k] != s[i])
	    count++;
	} else {}
      }
    }
  }

  printf("%d", count);

  return 0;
}
