#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    char S[N];
    scanf("%s", &S);
    printf("%s\n", S);
    int i, j, k, ans = 0;
    for(i = 0; i < N-2; ++i){
        for(j = i+1; j < N-1; ++j){
            for(k = j+1; k < N; ++k){
                if(j-i == k-j){ continue; }
                if(S[i] == S[j] || S[i] == S[k] || S[j] == S[k]){ continue; }
                ans += 1;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}