
#include <iostream>
using namespace std;

int main(void) {
    long int N,c = 0,i,j,k;
    char S[4000];
    scanf("%ld",&N);
    
    scanf("%s",S);
    for (i=0;i<N;++i){
       for (j=1+i;j<N;++j){
       for (k=1+j;k<N;++k){
           if((j-i)!=(k-j)){
           if(S[i]!=S[j] && S[i]!=S[k] && S[j]!=S[k]){
               c = c + 1;
           }
           }
       }
       }
    }
  cout << c << "\n"; 
  return 0;
}