#include <stdio.h>

int main() 
{

    char str[4001];
    int f;
    int count = 0;
    int i, j, k;
    scanf("%d %s", &f, str);

    for( i = 0; i < f-3; i++ ){
        for( j = i+1; j < f-1; j++ ){
            for( k = j+1; k < f; k++ ){
                if ( (j - i) != (k - j) ){
                    if ( str[i] != str[j] && str[i] != str[k] && str[j] != str[k] ){
                        count++;
                    }
                }
            }
        }
    }

    printf("%d", count);

    return 0;

}

