#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    string S;
    cin>>S;
    int counter=0;
    for(int j=1; j<N-1; j++){
        int t=j;
        int u=N-1-j;
        for (int i=1; i<=t; i++){
            for(int k=1; k<=u; k++){
                if(i==k) continue;
                
                if(S[j-i]!=S[j] && S[j]!=S[j+k] && S[j-i]!=S[j+k]) counter++;
            }
        }
        
    }
    cout<<counter<<endl;
}
