#include    <stdio.h>
#include    <string.h>

int main(void)
{
    int n;
    char    s[4000];
    int	ans = 0;

    if (fscanf(stdin, "%d", &n) != 1)
	return 0;
    if (fscanf(stdin, "%s", s) != 1)
	return 0;
    if (strlen(s) != n)
	return 0;
    for (int i = 0; i < n; i++) {
	for (int j = i+1; j < n; j++) {
	    for (int k = j+1; k < n; k++) {
		if ((i != j && i != k && j != k)
			&& (j - i != k - j)) {
		    if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
			ans++;
		    }
		}
	    }
	}
    }

    printf("%d\n", ans);
    return 0;
}

/*
 * vim:smartindent:sw=4:sts=4:co=84:nu:wm=78:
 */
