#include<stdio.h>

int main (void){
    int N;
    char S[4000];
    char c;
    int count=0;
    int i,j,k;

    scanf("%d",&N);
    scanf("%c",&c);
    for(i=0;i<N;i++){
        scanf("%c",&S[i]);
    }

    for(k=0;k<N;k++){
        for(j=0;j<k;j++){
            for(i=0;i<j;i++){
                if(2*(j+1)==i+k+2){
                    continue;
                }else if(S[i]==S[j]){
                    continue;
                }else if(S[i]==S[k]){
                    continue;
                }else if(S[j]==S[k]){
                    continue;
                }

                count++;
            }
        }

    }

    printf("%d",count);

    return 0;
}