#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
long long n,s;
string a;
int main()
{
    cin>>n;
    cin>>a;
    for (int i=0;i<n;i++)
    for (int j=i+1;j<n;j++)
    for (int k=j+1;k<n;k++)
    {
        if (j-i!=k-j)
        if ((a[i]!=a[j]&&a[j]!=a[k])&&(a[k]!=a[i])) s++;
    }
    cout<<s;
}
