#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const double PI = acos(-1);  // PI = 3.141593...

int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            for(int k = j+1; k < n; ++k) {
                if(j - i == k - j) {
                    continue;
                }
                else if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
                    ans += 1;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
