#include <cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	int n;
        string s; 
       cin>>n>>s;
	map<char,int> count_;
	for(int i=0; i<n; i++)
                    count_[s[i]]++;
	ll res = (ll)count_['R'] * count_['G'] * count_['B'];
	for(int i=0; i<n-2; i++)
		for(int j=i+1,k=i+2; k<n;  k+=2,j++)
			if((s[i]^s[j]^s[k]) == ('R'^'G'^'B')) 
                                     res--;
	cout<< res <<endl;
}
