#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt[3] = { 0 };
	rep(i, n) {
		if (s[i] == 'R') cnt[0]++;
		if (s[i] == 'G') cnt[1]++;
		if (s[i] == 'B') cnt[2]++;
	}
	int ans = 1;
	rep(i, 3) ans *= cnt[i];
	rep(j,n){
		rep(i,j ) {
			int k = 2 * j - i;
			if (k < n) {
				if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
					ans--;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}