#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
    int N;
    char buf[5000];
    char s[5000];
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf,"%d",&N);
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf,"%s",s);   
    //printf("%d %s\n",N,s);
    long long int ans=0;
    
    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            for(int k=j;k<N;k++){
                if(i>j)continue;
                if(j>k)continue;
                if(i>k)continue;
                if((j-i)==(k-j))continue;
                if(strncmp(&s[i],&s[j],1)==0)continue;
                if(strncmp(&s[j],&s[k],1)==0)continue;
                if(strncmp(&s[k],&s[i],1)==0)continue;
                ans++;
                //printf("%d %d %d %c %c %c\n",i,j,k,s[i],s[j],s[k]);    
            }
        }
    }
    printf("%lli\n",ans);
    return 0;
}