int main(void){
  unsigned int i,j,k;
  unsigned int len;
  unsigned int cnt = 0;
  scanf("%d",&len);
  char str[len];
  scanf("%s",str);
  for(i = 0;i < len-2;i++){
    for(j = i+1;j < len-1;j++){
      for(k = j+1;k < len;k++){
        if((j-i) ==(k-j)) break;
        if((str[i] != str[j]) && (str[j] != str[k]) && (str[k] != str[i])){
          cnt++;
        }
      }
    }
  }
  printf("%d",cnt);
  return 0;
}
