#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  char s[n+1];
  scanf("%s", s);

  long count = 0;

  for (long i = 0; i < n; i++) {
    if (s[i] != 'R') {
      continue;
    }
    for (long j = 0; j < n; j++) {
      if (s[j] != 'G') {
        continue;
      }
      for (long k = 0; k < n; k++) {
        if (s[k] != 'B') {
          continue;
        }
        if (j-i == k-j) {
          continue;
        }
        count++;
      }
    }
  }

  printf("%ld\n", count);

  return 0;
}