#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;


int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	rep(i,n-2){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				if (j-i==k-j)continue;
				if (s[i]==s[j]) continue;
				if (s[i]==s[k]) continue;
				if (s[k]==s[j]) continue;
				cnt++;

			}
		}
	}
	cout<<cnt;


}
