#include <stdio.h>

int main(int argc, char const *argv[])
{
	char str[4000];
	int n;
	scanf("%d",&n);
	scanf("%s",str);

	int i,j,k,t=0;

	for(i=1;i<=n-2;i++){
		for(j=i+1;j<=n-1;j++){
			for(k=j+1;k<=n;k++){
				if(str[i-1]!=str[j-1]&&str[j-1]!=str[k-1]&&str[k-1]!=str[i-1]&&(j-i)!=(k-j)){
					t++;	
				}
			}
		}
	}

	printf("%d\n",t );
	return 0;
}