#include <stdio.h>

int main(void) {

	int n, i, r = 0, g = 0, b = 0, ans = 0, frg = 0;
	int rn[4000], gn[4000], bn[4000];
	char s[4001];

	scanf("%d", &n);
	scanf("%s", s);

	for (i = 0; i < n; i++) {
		if (s[i] == 'R') {
			rn[r] = i;
			r++;
		}
		else if (s[i] == 'G') {
			gn[g] = i;
			g++;
		}
		else {
			bn[b] = i;
			b++;
		}
	}
	for (r = 0; frg == 0; r++)
		for (g = 0; frg == 0; g++)
			for (b = 0; frg == 0; b++) {
				if (gn[g] - rn[r] != b[n] - gn[g]) ans++;
			}

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

	return 0;
}