#include<stdio.h>
int main()
{
  int i,j,k;
  int N,sum = 0;
  scanf("%d", &N);
  char S[N];
  scanf("%s", S);
  for(i = 0; i < N-2; i++)
    for(j = i+1; j < N-1; j++)
      for(k = j+1; k < N; k++)
        if(j - i != k - j)
          if(S[i] != S[j] && S[i] != S[k] && S[j] != S[k])
            sum = sum + 1;
  printf("%d", sum);
}