#include <stdio.h>

int main (void)
{
 int n,i,j,k,sum=0;
 char s[4000];
  
  scanf("%d", &n);
  scanf("%s", &s);
  
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(k=j+1;k<n;k++){
        if(s[i] != s[j]&&s[i] != s[k]&&s[j] != s[k]&& j-i != k-j)
          sum++;
      }
    }
  }
  
  printf("%d", sum);
  
  return 0;
}