#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define f first
#define s second
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define fast 
#define f first
#define s second
#define endl "\n"
#define pie 3.1415926535

int main(){
    int n;
    cin >>n;
    string s;
    cin >> s;
  
    long long sum = 0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(s[i] != s[j] && s[j]!= s[k] && s[i]!=s[k] && (j-i)!=(k-j))
                    sum++;
            }
        }
    }
    cout << sum<<endl;
    return 0;
    
}




