#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n = 0;
	string s;
	cin >> n >> s;
	int count = 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(s[i] != s[j] && s[i] != s[k] && s[j] != s[k]){
					if((j-i) != (k-j)){
						count += 1;
					}
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}
