#include<stdio.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)

char s[4010];
int main(){
	int n;
	scanf("%d %s",&n,s);
	int ans=0;
	rep(m,0,n)rep(d,0,n)if(m-d>=0&&m+d<n){
		if(s[m-d]!=s[m]
		   &&s[m]!=s[m+d]
		   &&s[m+d]!=s[m-d])ans++;
	}
	long long c[300]={};
	rep(i,0,n)c[s[i]]++;
	printf("%lld",c['R']*c['G']*c['B']-ans);
}