#include <stdio.h>
int main()
{
    int n;
    long long c=0;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", &s);

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]==s[j]) continue;
            for(int k=j+1;k<n;k++){
                if(j-i == k-j) continue;
                if(s[i]!=s[j] && s[j]!=s[k] && s[i]!=s[k]) c++;
            }
        }
    }
    printf("%lld\n", c);
    return 0;
}
