#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;


int main(){
  int N; cin >> N;
  string S; cin >> S;
  
  vector<int> Rs;
  vector<int> Gs;
  vector<int> Bs;
  
  for(int i = 0; i < N; i++){
    if(S.at(i) == 'R') Rs.push_back(i);
    else if(S.at(i) == 'G') Gs.push_back(i);
    else Bs.push_back(i);
  }
  
  int NR = Rs.size();
  int NG = Gs.size();
  int NB = Bs.size();
  
  int res = 0;
   for(int i = 0; i < NR; i++){
     for(int j = 0; j < NG; j++){
       for(int k = 0; k < NB; k++){
        vector<int> temp;
        temp.push_back(Rs.at(i));
        temp.push_back(Gs.at(j));
        temp.push_back(Bs.at(k));
        sort(temp.begin(), temp.end());
        if((temp.at(2) - temp.at(1)) != (temp.at(1) - temp.at(0))) res++;
         //cout << temp.at(0) << " " << temp.at(1) << " " << temp.at(2) << endl;
      }
    }
  }
  
  cout << res << endl;
  //cout << S << endl;
  
}