#include <bits/stdc++.h>
using namespace std;
int main (){
  int i,j,k,t=0;
  int n;
  char a,b,c;
  string s;
  cin>>n>>s;
  for(i=1;i<=n-2;i++){
    //cout<<1;
    for(j=i+1;j<=n-1;j++){
      //cout<<2;
      for(k=j+1;k<=n;k++){
        a=s[i-1];b=s[j-1];c=s[k-1];
        //cout<<a<<b<<c<<j-1<<k-j;
        if((a!=b&&b!=c&&a!=c)&&(j-i)!=(k-j)){
          t++;
        }
      }
    }
  }
  cout<<t<<endl;
  return 0;
}