#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
const int INF = 1e9;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int r_cnt,g_cnt,b_cnt;
    r_cnt = count(s.cbegin(), s.cend(), 'R');
    g_cnt = count(s.cbegin(), s.cend(), 'G');
    b_cnt = count(s.cbegin(), s.cend(), 'B');
    
    int ans = r_cnt*g_cnt*b_cnt;
    for(int i=0;i<n;i++){
        for(int d=0;d<n;d++){
            int j = i + d;
            int k = j + d;
            if(k >= n) break;
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans -= 1;
        }
    }
    cout << ans << endl;
}