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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int r = 0, g = 0, b = 0;
  for (char c : S) (c == 'R' ? r++ : c == 'G' ? g++ : b++);
  long ans = (long) r * g * b;
  for (int i = 0; i < N; i++) {
    for (int sp = 1; i + sp + sp < N; sp++) {
      if ((S.at(i) ^ S.at(i + sp) ^ S.at(i + sp + sp)) == 87) ans--;
    }
  }
  cout << ans << "\n";
}