#include <stdio.h>
int main() {
	int n, cnt = 0;
	char s[4001];
	scanf("%d%s", &n, s);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (j - i != k - j && s[i] != s[j] && s[i] != s[k] &&
					s[j] != s[k]) {
					cnt++;
				}
			}
		}
	}
	printf("%d\n", cnt);
	return 0;
}