#include <stdio.h>

int main(void) {
	int n, num = 0; 
	char s[4000];

	scanf("%d", &n);
	scanf("%s", 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 (s[i] != s[j] && s[i] != s[k] && s[j] != s[k] && j - i != k - j)
					num = num + 1;
			}
		}
	}

	printf("%d", num);

	return 0;
}