#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    ll n,ans=0;
    string s;
    cin >> n >> s;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            if(s[i] == s[j])continue;
            for(ll k=j+1;k<n;k++){
                if(2*j == k + i)continue;
                if(s[i]==s[k])continue;
                if(s[j]==s[k])continue;
                ans++;
            }
        }
    }
    cout << ans << endl;
}