#include<stdio.h>

int main(void)
{
	unsigned long int a, b, c, N;
	int sum = 0;
	char mozi[4001];
	int tab;
	
	scanf("%ld", &N);
	scanf("%s", &mozi);
	
	/*
	for (a = 1; a <= (N - 3); a++) {
		for (b = (a + 1); b <= (N - 1); b++) {
			if (mozi[a - 1] != mozi[b - 1]) {
				for (c = (b + 1); c <= N; c++) {
					if ((mozi[a - 1] != mozi[c - 1]) && (mozi[b - 1] != mozi[c - 1])) {
						if ((b - a) != (c - b)) {
							sum++;
						}
					}
				}
			}
		}
	}
	*/

	for (a = 1; a <= N; a++) {

		if ('R' == mozi[a - 1]) {
			for (b = 1; b <= N; b++) {

				if ('B' == mozi[b - 1]) {

					for (c = 1; c <= N; c++) {
						if ('G' == mozi[c - 1]) {

							if (((abs(a - c)) != (abs(b - c))) && ((abs(a - b)) != (abs(a - c))) && ((abs(a - b)) != (abs(b - c)))) {
								sum++;
							}

						}
					}
				}
			}
		}
	}

	printf("%ld", sum);

	return 0;
}