#include "bits/stdc++.h"
#define lp(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using l = long;
using vi = vector<int>;
using vl = vector<l>;
using vll = vector<ll>;
using vvl = vector<vector<l>>;
using vvll = vector<vector<ll>>;
using pll = pair<ll, ll>;
using un = unsigned;

int n, res = 0;
string s;

void f(int cnt, int num, vi v)
{
	const int vs = v.size();
	if (vs == 3) return;
	else if (vs < 3) {
		for (int i = num; i < n; i++) {
			if (num < i) {
				vi tmp = v;
				tmp.push_back(i);
				f(cnt + 1, i, tmp);
				if (tmp.size() == 3 && s[tmp[0]] != s[tmp[1]]
					&& s[tmp[0]] != s[tmp[2]]
					&& s[tmp[1]] != s[tmp[2]]
					&& (tmp[1] - tmp[0] != tmp[2] - tmp[1])) {
					res++;
				}
			}
		}
	}
}

int main()
{
	cin >> n >> s;
	f(0, 0, vi(1, 0));
	cout << res;
}

