#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

int n;
char s[4444];

main(){
    scanf("%d", &n);
    scanf("%s", s);
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<i; j++){
            for(int k=0; k<j; k++){
                if(i-j != j-k){
                    if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans++;
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}