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