#include <bits/stdc++.h>
#include<iostream>
#include <vector>
using namespace std;
int main() {
    int N; string S;
    cin >> N >> S;
    int64_t r, g, b;
    for (auto c : S) {
        if (c == 'R') {
            r++;
        } else if (c == 'G') {
            g++;
        } else {
            b++;
        }
    }

    int64_t all = r + g + b;
    int64_t sub = 0;
    for (int i=0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if(S[i] == S[j]) {
                continue;
            }

            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) {
                continue;
            }

            sub++;
        }
    }

    cout << all - sub << endl;

    return 0;
}