#include <stdio.h>
#include <stdlib.h>

int main() {
	int N;
	char *S;
	int sum_of_R = 0;
	int sum_of_G = 0;
	int sum_of_B = 0;
	int *array_of_R;
	int *array_of_G;
	int *array_of_B;
	int i, j, k;
	int count_R = 0;
	int count_G = 0;
	int count_B = 0;
	int a, b, c;
	int sum = 0;
	int sum_cont = 0;

	scanf("%d", &N);
	S = (char*)malloc(N * sizeof(char));
	scanf("%s", S);

	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
					&& S[i] != S[j]
					&& S[i] != S[k]
					&& S[j] != S[k]) {
					sum++;
				}
			}
		}
	}

	printf("%d\n", sum);
	return 0;
}

