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

int main(int argc, char *argv[]){
        long long all = 0;
        char *str;
        long long sum = 0;
        scanf("%lld\n", &all);
        str = (char *)malloc(all+1);
        fgets(str,all+1,stdin);
        char tmp;
        for(long long i = 0; i <= all-3; i++){
                for(long long j = i+1;j <= all-2; j++){
                        for(long long k = j+1;k <= all-1; k++){
                                if(((j - i) != (k - j)) && (str[i] != str[j] && str[i] != str[k] && str[j] != str[k])){
                                        sum++;
                                        //printf("%c:%c:%c\n", str[i], str[j],str[k]);
                                }else{
                                        continue;
                                }
                        }
                }
        }
        printf("%lld\n",sum);
        return 0;
}