#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N,count=0;
  cin>>N;
  vector<char> S(N);
  rep(i,N){cin>>S[i];}
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      for(int k=1;k<=N;k++){
        if(!(i<j&&j<k)){continue;}
        else if(!((j-i)==(k-j))){
          if(!(S[i-1]==S[j-1])&&!(S[i-1]==S[k-1])&&!(S[j-1]==S[k-1])){
            count++;
          }
        }
      }
    }
  }
  cout<<count<<endl;
}