void main() {
    int n, sum = 0;
    char* str;
    scanf("%d", &n);
    str = malloc((n+1) * sizeof(char));
    scanf("%s", str);

    for (int i = 0; i <= n - 3;i++){
        for (int j = i+1; j <= n-2; j++){
            for (int k = j+1; k <= n-1; k++){
                if (str[i] != str[j] && str[i] != str[k] && str[k] != str[j] && k - j != j - i)
                    sum++;
            }
        }
    }

    printf("%d", sum);
}