#include <iostream>
#include <string>
using namespace std;

int main() {
	int n = 0;
	cin >> n;
	char s[4000] = { 0 };
	cin >> s;
  	int sum = 0;
	int i, j, k;
	for (i = 0; i <= n - 3; i++)
		for (j = i + 1; j <= n - 3 + 1; j++)
			for (k = j + 1; k <= n - 3 + 2; k++) {
              	int cur = k + i;
				if (s[i] != s[j] && s[k] != s[j] && s[k] != s[i] && cur != 0) {
						sum++;
				}
			}
	cout << sum << endl;
	return 0;
}
