#include <stdio.h>

int main(void) {
    int n;
    char s[n];
    scanf("%d", &n);
    scanf("%s", &s);
    int ans;
    ans = 0;

    for (int i = 0; i <= n-2; i+=1) {
        for (int j = i + 1; j <= n - 1; j+=1) {
            for (int k = j + 1; k <= n; k += 1) {
                if (s[i] != s[j]) {
                    if (s[j] != s[k]) {
                        if (j-i != k-j) {
                            ans += 1;
                        }
                    }
                }
            }
        }
    }
}