#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  char s[n];
  scanf("%s", s);
  
  int counter = 0;
  int i, j, k;
  
  for(i = 0; i < n-2; i++){
    for(j = i+1; j < n-1; j++){
      if(s[i] == s[j])
        continue;
      for(k = j+1; k < n; k++){
        if(s[i] == s[k] || s[j] == s[k] || (j - i) == (k - j))
          continue;
        else
          counter++;
      }
    }
  }
  printf("%d", counter);
}