#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n;
	char *s;
	int x = 0;
	scanf("%d", &n);
	s = (char *)malloc(sizeof(char) * (n+1));
	scanf("%s", s);
	for(int i=0; i<n-2; i++){
		for(int j=i+1; j<n-1; 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)){
					x++;
				}
			}
		}
	}
	printf("%d\n", x);
	return 0;
}