#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++);
#define ll long long
int main(){
	ll n,count=0;
	string s;
	cin >> n >> s;
	vector<int> r;
	vector<int> g;
	vector<int> b;
	for(int i=0;i<n;i++){
		if(s[i]=='R')r.push_back(i);
		else if(s[i]=='G')g.push_back(i);
		else if(s[i]=='B')b.push_back(i);
	}
	for(int i:r){
		for(int j:g){
			for(int k:b){
				if(i<j&&j<k&&k-j!=j-i)count++;
			}
		}
	}
	cout << count << endl;
}
