#include <stdio.h>

int main(void) {
    int n, count;
    char s[4001];
    scanf("%u %s", &n, s);

    int i, j, k;

    count = 0;
    for (k = 0; k < n; k++) {
        for (j = 0; j < k; j++) {
            for (i = 0; i < j; i++) {
                if (j - i != k - j) {
                    if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
                        count++;
                    }
                }
            }
        }
    }

    printf("%d\n", count);

    return 0;
}