#include <bits/stdc++.h>
using namespace std;
 

int main() {
int N;
cin >> N;
string S;
cin >> S;
int ans = 0;
for(int i = 0; i < N; i++){
for(int j = i+1; j < N; j++){
for(int k = j+1; k < N; k++){
    int a, b, c;
if(S[i] == 'R') a = 1;
if(S[i] == 'G') a = 2;
if(S[i] == 'B') a = 3;

if(S[j] == 'R') b = 1;
if(S[j] == 'G') b = 2;
if(S[j] == 'B') b = 3;

if(S[k] == 'R') c = 1;
if(S[k] == 'G') c = 2;
if(S[k] == 'B') c = 3;


    if(i != j && i != k && j != k && j - i != k - j && a != b && a != c && b != c){
ans++;
    }
}
}    
}
cout << ans << endl;
}
