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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r=0, g=0, b=0;
  for (int i=0; i<n; i++) {
    if (s[i] == 'R') r++;
    else if (s[i] == 'G') g++;
    else b++;
  }
  int ans = r * g * b;

  for (int m=1; m<n; m++) {
    for (int i = 0; (i+m+m)<n; i++) {
      char x, y, z;
      x = s[i];
      y = s[i+m];
      z = s[i+m+m];
      if (x != y && y != z && z != x) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}