#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    char arr[n];
    scanf("%s", arr);
    int ans = 0;
    for (int r = 0; r < n; r++)
    {
        for (int g = r; g < n; g++)
            if (arr[g] != arr[r])
                for (int b = g; b < n; b++)
                    if (arr[b] != arr[g] and arr[b] != arr[r] and g - r != b - g)
                        ans += 1;
    }
    printf("%d\n", ans);
}
