#include <stdio.h>

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

    scanf("%d", &N);
    scanf("%s", S);

    for (i = 1; i < N-1; i++) {
        for (j = i+1; j < N; j++) {
            for (k = j+1; k <= N; k++) {
                if (j-i != k-j) {
                    if (S[i-1] != S[j-1] && S[i-1] != S[k-1] && S[j-1] != S[k-1]) {
                        cnt++;
                    }
                }
            }
        }
    }
    printf("%d\n", cnt);
}