#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

vector<int> v;

int main() {
    int n;
    string s;
    cin >> n >> s;

    int r = 0, g = 0, b = 0;
    foreach(i, s){
        if(i == 'R'){
            r++;
        }else if(i == 'G'){
            g++;
        }else{
            b++;
        }
    }

    int rgb = r * g * b;

    int cnt = 0;
    int len = size(s);
    rep(i, len){
        FOR(j, i + 1, len){
            if(s[i] == s[j]){
                continue;
            }
            int k = 2 * j - i;

            if(k >= len || s[j] == s[k] || s[k] == s[i]){
                continue;
            }

            cnt++;
        }
    }

    println(rgb - cnt);
}
