#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
  int n,i,j,k,ans=0;
  char *s;

  scanf("%d",&n);
  s = (char *)malloc(sizeof(char) * n);
  if(s == NULL) exit(0);

  scanf("%s",s);
  for(i=0;i<n;i++){
    for(j=strspn(&s[i], s);j<n;j++){
      for(k=strspn(strcat(&s[i],&s[j]), s);k<n;k++){
        if(j-i!=k-j){
          ans++;
        }
      }
    }
  }
  free(s);

  printf("%d\n",ans);
  return 0;
}
